Skip to main content

pytest-graded

Run each test script as one pytest item, and fail a script that graded nothing.

pytest's own rule is that a test that asserts nothing passes. For a suite of test scripts, that rule lets through the most expensive failure there is: a script whose loop matched no input, exited 0, and proved nothing. This plugin runs each script in its own process, counts the cases it graded, and gives one of four verdicts.

The four verdicts

verdict exit code cases graded pytest outcome
PASSED 0 one or more passed
FAILED non-zero one or more failed, with the script's FAIL lines
DID NOT RUN non-zero none failed, with the last line of the traceback
GRADED NOTHING 0 none failed

A graded case is a line of the script's output, on stdout or stderr, that starts with ok or FAIL followed by white space, optionally indented:

ok    the thermostat reads 21.5
FAIL  the shade reports its battery
      expected a percentage, got null

Lines indented under a FAIL line are carried into pytest's failure report.

Install

pip install git+https://github.com/ploutosservices/pytest-graded

pytest finds the plugin by its entry point; no -p flag is needed.

Configure

In pytest.ini, pyproject.toml ([tool.pytest.ini_options]) or setup.cfg:

setting default meaning
graded_files tests-*.py glob of script names collected, one item per file
graded_strip_env none environment variable names removed before each script runs, so no script reaches, for example, a real alert endpoint

Each script runs with the same Python interpreter as pytest, from the project's root directory.

Run

python -m pytest                        # every script matching graded_files
python -m pytest tests-shades.py        # one script

Tests

The four verdicts are each drawn from a drill script in tests/drills/:

pip install -e .
python -m pytest

Licence

Apache-2.0. See LICENSE and NOTICE.

Metadata

Release files for pytest-graded 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-graded 0.1.0
File Size Uploaded Provenance Actions
pytest_graded-0.1.0.tar.gz 8.8 kB Without provenance Details for pytest_graded-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytest-graded 0.1.0
File Interpreter ABI Platform Actions
pytest_graded-0.1.0-py3-none-any.whl Python 3 none any Details for pytest_graded-0.1.0-py3-none-any.whl

Total release size: 17.7 kB

Release files / pytest_graded-0.1.0.tar.gz

Download URL pytest_graded-0.1.0.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f4358489216a9ad823b423813b3eba1d1f3b3b9da13e135002675c06cf3eacd1
BLAKE2b-256 checksum
How to use checksums
8b9a0994ab2bd8cdb053bc37a9f5a153d5d90a136a54985d5b5622ca3ebc5ca1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / pytest_graded-0.1.0-py3-none-any.whl

Download URL pytest_graded-0.1.0-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4f81f560c2a817135d7352832953f2812f05e7f0d3bd8761f596f6a602c1c577
BLAKE2b-256 checksum
How to use checksums
729a7f8b7577899508776e178e8eba9d9e6e4515b98bed1e350e756ef49f68ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Security for pytest-graded 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page