Skip to main content

pytest-sources

PyPI Python Tests

pytest-sources is a plugin for pytest that allows tests to be run on multiple sources.

This is handy for autograding coursework, take-home interview screening, and conformance suites across implementation variations.

The full guide lives in docs/GUIDE.md; the internals are described in docs/DESIGN.md.

Features

  • Run one test suite against many source directories, each test parameterised per source.
  • One process per source isolation enabled when using -n.
  • Per-source results table, with grid views of source × test.
  • Per-source failure budget with --sources-maxfail.
  • Tests run with the source on sys.path and as the working directory, so submissions can import and read their own files.
  • Sources per test via @pytest.mark.sources, opt-outs via no_sources and no_chdir.

Installation

pip install pytest-sources

Quick start

pytest --sources "sources/*" -n auto
def test_add(source):
    solution = source.import_module("solution")
    assert solution.add(2, 3) == 5
tests/test_add.py::test_add[sources/alice] PASSED
tests/test_add.py::test_add[sources/bob]   FAILED

See source's full API for import_module, chdir, and the rest.

Reference

Options

option ini default description
--sources GLOB (repeatable) sources = [...] none Run every test once per matching source directory. The option replaces the ini list.
-n N / -n auto 0 Workers (pytest-xdist). auto starts one worker per source, capped at the CPU count. Without workers, sources share one process and lose isolation.
--dist MODE load Split a source into more work items: loadfile, loadscope, loadgroup.
--sources-summary VIEW counts View test results as a table with options: counts, sources, tests, none.
--sources-maxfail N 0 (off) Per-source failure budget. Exact by default, approximate when a --dist grouping mode splits the source over processes.
--skip-marker-sources skip_marker_sources false Skip tests with the sources marker.

Markers

marker description
@pytest.mark.sources(*globs) Run this test against its own sources instead of the --sources set.
@pytest.mark.no_sources Run this test once, exempt from being tested against each source.
@pytest.mark.no_chdir Keep the working directory pytest was started in.

Todo

  • Support for --dist each and --dist worksteal.

Metadata

Release files for pytest-sources 0.3.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-sources 0.3.0
File Size Uploaded
pytest_sources-0.3.0.tar.gz 18.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-sources 0.3.0
File Interpreter ABI Platform
pytest_sources-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 46.4 kB

Release files / pytest_sources-0.3.0.tar.gz

Download URL pytest_sources-0.3.0.tar.gz
Size 18.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5600de365acf7dc635024c04b332e66d0fa17de0e35feec582e2b89c79c12f09
BLAKE2b-256 checksum
How to use checksums
80689295d029068c9f1c440b3983090701c1bb1265c27cec05de5c6dbbd18f0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 23, 2026.

Transparency log

Release files / pytest_sources-0.3.0-py3-none-any.whl

Download URL pytest_sources-0.3.0-py3-none-any.whl
Size 27.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4f2f56b922d5872e1811b8008582570459c20455075e5fc7a08ea66dfb828a34
BLAKE2b-256 checksum
How to use checksums
f4bd56f8e3279f15a76e0848e1bdfe7aa46200c0210066c7e12d9af411d544b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 23, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

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