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.1

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.1
File Size Uploaded
pytest_sources-0.2.1.tar.gz 16.4 kB Details

Built distribution (wheel)

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

Total release size: 40.3 kB

Release files / pytest_sources-0.2.1.tar.gz

Download URL pytest_sources-0.2.1.tar.gz
Size 16.4 kB
Tags Source
SHA-256 checksum
How to use checksums
88fb217b0562648ee258cf5c8ad0017db97e50b954eac191d1f0b6aae2d20cbf
BLAKE2b-256 checksum
How to use checksums
0efbad7adbe6b012a540daf6936178470066bf87356c0f045d55ef6e956c6c38
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 20, 2026.

Transparency log

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

Download URL pytest_sources-0.2.1-py3-none-any.whl
Size 23.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
faff731e57dce28a49ba1591865daa74c35d37db179863688b3712f5b0e6f0cf
BLAKE2b-256 checksum
How to use checksums
37c936eeecf4f57bba5f9f76758598efc8d911308800c899de392eb07af2bd06
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 20, 2026.

Transparency log

Release history Release notifications | RSS feed

0.3.0

2 release files

This release

0.2.1 This release

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