Pytest plugin for managing test artifacts
You can install "pytest-artifacts" from PyPI:
pip install pytest-artifactsAttach the artifacts fixture to your pytest test case. The attribute artifacts.dir is a dedicated directory for the test case.
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.
Configurations may be set in pyproject.toml, pytest.ini, or passed as command line options.
# pyproject.toml
[tool.pytest]
artifacts_dir = .artifacts/# pytest.ini
[pytest]
artifacts_dir = .artifacts/pytest --artifacts-dir .artifacts/ tests/Contributions are very welcome.
Distributed under the terms of the MIT license, "pytest-artifacts" is free and open source software
If you encounter any problems, please file an issue along with a detailed description.