Skip to main content

Pytest plugin for managing test artifacts

Project description

pytest-artifacts

PyPI version Python versions See Build Status on GitHub Actions

Pytest plugin for managing test artifacts

Installation

You can install "pytest-artifacts" from PyPI:

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.

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.

# pyproject.toml
[tool.pytest]
artifacts_dir = .artifacts/
# pytest.ini
[pytest]
artifacts_dir = .artifacts/
pytest --artifacts-dir .artifacts/ tests/

Contributing

Contributions are very welcome.

License

Distributed under the terms of the MIT license, "pytest-artifacts" is free and open source software

Issues

If you encounter any problems, please file an issue along with a detailed description.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_artifacts-0.3.0.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_artifacts-0.3.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file pytest_artifacts-0.3.0.tar.gz.

File metadata

  • Download URL: pytest_artifacts-0.3.0.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pytest_artifacts-0.3.0.tar.gz
Algorithm Hash digest
SHA256 47813a05fdbe32dcb00a53b5ab8b18e59144734fdd96d455b97e24991f64d7dc
MD5 235464e483ddc7ef61e9fd4da08573f6
BLAKE2b-256 eb121af38e0dfe717d57652e7b7fcb46735e0486b68c6beb7be476987ed7e50a

See more details on using hashes here.

File details

Details for the file pytest_artifacts-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: pytest_artifacts-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pytest_artifacts-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 43225ab500cec60d9c3c20a75148939f163cf11ab93feaaaf87f779458452c7f
MD5 240291e694ff0926b74043ffb5055199
BLAKE2b-256 af6f2d8769b821f6b10d7b3721d75fee8d41b25702ed0ce10ab2ec2d94899bef

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page