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.
--sources-delimiter CHAR sources_delimiter + Separator between parameters in a test id. No source path may contain it.
--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.
  • More efficient test collection. All tests are collected again per source spin-up.

Metadata

Release files for pytest-sources 0.2.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.2.0
File Size Uploaded
pytest_sources-0.2.0.tar.gz 16.5 kB Details

Built distribution (wheel)

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

Total release size: 40.3 kB

Release files / pytest_sources-0.2.0.tar.gz

Download URL pytest_sources-0.2.0.tar.gz
Size 16.5 kB
Tags Source
SHA-256 checksum
How to use checksums
33c16b82ee807a138e2bd1c058d396da4cdc093d56494d6ce2ad60d53660ecab
BLAKE2b-256 checksum
How to use checksums
df36cce1b23e7b0f4305516631fe04349e7df826a175702868cc94fbd5f40e97
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 19, 2026.

Transparency log

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

Download URL pytest_sources-0.2.0-py3-none-any.whl
Size 23.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
31f2ef0bb09d76f5c8b4ea026039c7f12026ea1b51909bb16f1970bab2f76133
BLAKE2b-256 checksum
How to use checksums
9d85f53909083a9401d5daf057c221fb9ca37bcd15fc1f404dd6bb2ba1cf191a
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 19, 2026.

Transparency log

Release history Release notifications | RSS feed

0.3.0

2 release files

0.2.1

2 release files

This release

0.2.0 This release

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