Repository navigation
Closed
Labels
Description
Part of the Python (pytest) adapter: #61.
Before DiffCI can select Python tests, it needs to know which files pytest treats as tests. This issue is only that piece: no import graph, no commands.
Scope
- A small function in
src/repo/adapters/python.ts(new file) that takes the repository's file list, pytest configuration, and (when known) the paths the CI command passes to pytest, and returns the test files. - Default discovery:
test_*.pyand*_test.py. - Honour
testpathsandpython_filesfrompytest.ini,pyproject.toml([tool.pytest.ini_options]),tox.iniorsetup.cfg. testpathsis only where pytest starts looking by default, not a filter: paths passed on the command line override it. Use the command's paths when there are any, otherwisetestpaths, otherwise the repository root.- Return a blocker for anything it can't read statically (for example a
conftest.pythat definespytest_collect_file, orpython_filesset from a plugin), and when the pytest invocation is unknown or can't be parsed. Never return a list built only fromtestpathsin that case.
Done when
- Unit tests cover: default layout,
src/layout, a customtestpaths, a custompython_files,testpaths = checkswith the command passingtests(onlytests/files returned), and one unsupported case that returns a blocker. - The function is exported but not yet registered in
REPOSITORY_ADAPTERS.
Safety rule: when the adapter is unsure, it adds a blockers entry so DiffCI runs the full suite. An empty graph must never look like "nothing affected".
New to DiffCI? Read the adapter guide and CONTRIBUTING.md. Sign off commits with git commit -s. Comment here to claim it, and ask questions on the issue at any point.
Activity
robertwmccarty-caelum commentedon Oct 30, 2026
Test-backed discovery boundary for #55 (not claiming or reserving the implementation).
I ran six isolated synthetic repositories with pytest 9.0.2,
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 python -m pytest --collect-only -q -p no:cacheprovider, and asserted the collected node IDs (all six checks passed):test_root.py,alpha_test.py,src/test_source.py, plustests/spec_ignored.pyspec_ignored.pyexcludedpytest.ini:testpaths = checks;checks/test_inside.py+tests/test_outside.pychecks/test_inside.pyteststests/test_outside.py— explicit CLI path overridestestpathspyproject.toml:[tool.pytest.ini_options] python_files = ["spec_*.py"]tests/spec_math.pycollected;tests/test_ignored.pyexcludedtox.ini:[pytest] testpaths = qa; python_files = check_*.py(on separate lines)qa/check_math.pysetup.cfg:[tool:pytest] testpaths = qa; python_files = check_*.py(on separate lines)qa/check_math.pySelection-safety implication:
testpathsis a default search starting point, not a permanent exclusion rule. A selector that drops every test outsidetestpathscan miss tests when the actual CI command supplies positional paths. For this initial discovery-only function, either model the CI invocation's collection roots explicitly or return a blocker when the invocation is unknown; do not treat an empty result as proof that no tests exist. This is consistent with the issue's full-suite fallback rule.Minimal reproduction for the third case:
Upstream references: pytest configuration reference and test discovery.
These are local pytest observations, not DiffCI integration tests; no repository code or CI configuration was changed. Prepared with AI assistance for a human BuddyLists / Linked AIs operator, not an independently operated agent account.
adityankale190895 commentedon Oct 30, 2026
Thanks @robertwmccarty-caelum, the six collection checks are a great reference, especially the third one. I hadn't accounted for an explicit command-line path overriding
testpaths.Adding this to the scope:
testpathsis the default place pytest starts looking, not a filter. The discovery function should take the collection paths from the CI command when it knows them, and fall back totestpaths, then the repo root, only when the command passes no paths.blockersentry rather than a list built only fromtestpaths.testpaths = checks, but the command passestests" alongside the existing ones.Your fixtures (the default layout,
pyproject,tox.iniandsetup.cfgvariants) map directly onto the "Done when" list, so whoever claims this can reuse them. Still open. Comment to claim.adityankale190895 commentedon Nov 7, 2026
Shipped in CLI 0.3.33 (Core 0fd9ed0) as part of the pytest adapter. Real-repository feedback is tracked in #75.