Metadata-Version: 2.4
Name: pytest-artifacts
Version: 0.3.0
Summary: Pytest plugin for managing test artifacts
Project-URL: Repository, https://github.com/ketozhang/pytest-artifacts
Project-URL: Documentation, https://github.com/ketozhang/pytest-artifacts
Project-URL: Bug Tracker, https://github.com/ketozhang/pytest-artifacts/issues
Author-email: "Keto D. Zhang" <keto.zhang@gmail.com>
Maintainer-email: "Keto D. Zhang" <keto.zhang@gmail.com>
License-Expression: MIT
License-File: LICENSE
Keywords: artifacts,plugin,pytest,testing
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: Pytest
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.10
Requires-Dist: pytest>=6.2.0
Description-Content-Type: text/markdown

# pytest-artifacts

[![PyPI version](https://img.shields.io/pypi/v/pytest-artifacts.svg)](https://pypi.org/project/pytest-artifacts)
[![Python versions](https://img.shields.io/pypi/pyversions/pytest-artifacts.svg)](https://pypi.org/project/pytest-artifacts)
[![See Build Status on GitHub Actions](https://github.com/ketozhang/pytest-artifacts/actions/workflows/main.yml/badge.svg)](https://github.com/ketozhang/pytest-artifacts/actions/workflows/main.yml)

Pytest plugin for managing test artifacts

## Installation

You can install "pytest-artifacts"  from [PyPI](https://pypi.org/project):

```bash
pip install pytest-artifacts
```

## Usage
Attach the `artifacts` fixture to your pytest test case. The attribute `artifacts.dir` is a dedicated directory for the test case.

```py
import time
import matplotlib.pyplot as plt

def test_benchmark(artifacts):
    times = range(1, 101, 10)
    elapsed = []
    for t in times:
        start_time = time.perf_counter()

        time.sleep(t)

        end_time = time.perf_counter()
        elapsed.append(end_time - start_time)

    plt.scatter(times, elapsed)
    with artifacts.open('benchmark.png') as f:
        plt.savefig(f)
```

```
.artifacts/
└── test_benchmark/
    └── benchmark.png
```

The test case directory is named after the test path, function name, and if any, the test parameter ID.

### Configure
Configurations may be set in `pyproject.toml`, `pytest.ini`, or passed as command line options.

```toml
# pyproject.toml
[tool.pytest]
artifacts_dir = .artifacts/
```

```ini
# pytest.ini
[pytest]
artifacts_dir = .artifacts/
```

```sh
pytest --artifacts-dir .artifacts/ tests/
```

## Contributing

Contributions are very welcome.

## License

Distributed under the terms of the [MIT](https://opensource.org/licenses/MIT) license, "pytest-artifacts" is free and open source software

## Issues

If you encounter any problems, please [file an issue](https://github.com/ketozhang/pytest-artifacts/issues) along with a detailed description.
