Skip to content

Releases: tuppl/pytest-sources

v0.3.0

Choose a tag to compare

@github-actions github-actions released this 23 Aug 15:32

Full Changelog: v0.2.1...v0.3.0

v0.2.1

Choose a tag to compare

@github-actions github-actions released this 20 Aug 20:03

Fixed

  • Fixed missing tests whose source wasn't the first parameter in the node id so they were treated as belonging to no source.

Full Changelog: v0.2.0...v0.2.1

v0.2.0

Choose a tag to compare

@github-actions github-actions released this 19 Aug 19:43

New Features

  • @pytest.mark.sources(*globs) now adds its sources to the run instead of narrowing the --sources set. A collection pass before the run finds marked sources, so they are scheduled, summarised and given a failure budget like declared ones.
  • --skip-marker-sources (ini skip_marker_sources) skips tests carrying a sources marker, and the extra collection pass that finds them.
  • A report header giving the source count, worker count and work items. Without workers it says so, and points at -n auto.
  • source_for is exported from the package.

Changes

  • Workers are opt-in. Passing --sources no longer starts them on your behalf; use -n as with plain pytest-xdist. -n auto starts one worker per source, capped at the CPU count.
  • --sources-maxfail is shared across processes through a per-run file, so it now combines with --dist loadfile, loadscope and loadgroup. The budget there is at most N failures plus any tests already running when the limit is reached. It is refused alongside a --tx spec that puts workers on another machine.
  • Spare workers are dealt to whichever source currently has the largest work item, rather than splitting every source equally. Five workers over three sources now use all five instead of leaving two idle.
  • Documentation moved to docs/GUIDE.md and docs/DESIGN.md, leaving the README as a reference.
  • Pipeline stage modules are separated from a _core/ package. from pytest_sources.source import ... no longer resolves; the top level package API is unchanged.

Fixed

  • A test that parametrises its own source argument is rejected with a usage error instead of silently colliding with the fanout.
  • The summary no longer fails on a test outcome it does not recognise, such as one another plugin introduces.

Full Changelog: v0.1.0...v0.2.0

v0.1.0

Choose a tag to compare

@github-actions github-actions released this 13 Aug 22:12

Run one test suite against many source trees. Every collected test runs once per source directory, with the source importable and the working directory inside it.

pytest --sources "sources/*"

Isolation

  • One process per source by default, so a crash or a hang takes down one submission rather than the run
  • Workers are recycled between sources, so sys.modules, globals and monkeypatching never leak across them
  • Composes with xdist's --dist loadfile, loadscope and loadgroup, which group within a source instead of replacing it
  • Warns when a module a source provides is already imported from elsewhere, which would otherwise grade every source against the same code

Writing tests

  • Tests need no fixture to be fanned out; the source is on sys.path and is the working directory either way
  • source fixture for when the test needs the identity: source.id, source.name, source.path, source / "data.txt", source.import_module(), source.chdir()
  • @pytest.mark.sources("sources/*_alt") narrows one test to a subset
  • @pytest.mark.no_sources runs a test once, @pytest.mark.no_chdir keeps the invocation directory

Reporting

  • Per-source results table after every run, with passed, failed, error, skipped, xfailed, xpassed and time
  • --sources-summary sources|tests for a grid of source × test, either orientation
  • --sources-maxfail=N gives each source its own failure budget, so one bad submission doesn't end the run

Configuration

  • --sources is repeatable, or set sources = [...] in your ini
  • --sources-delimiter changes the test ID separator if your paths contain +
  • Test IDs are source paths relative to the rootdir, so -k, --lf and nodeid selection work as usual

Known limitation

-n 0 and --dist no run every source in the calling process. That trades isolation for a debuggable single-process run; any other worker count gives each source its own.

Supported

Python 3.12–3.14, pytest 8–9, pytest-xdist 3.8+. Fully typed.