Skip to content

fix(python): follow pytest plugins that addopts loads with -p - #207

Merged
adityankale190895 merged 4 commits into
DiffCI:mainfrom
FredApps:fix/python-addopts-plugins
Nov 18, 2026
Merged

adityankale190895 merged 4 commits into
DiffCI:mainfrom
FredApps:fix/python-addopts-plugins

Conversation

@FredApps

Copy link
Copy Markdown
Contributor

Fixes #206

readPytestSettings now reads addopts and records the modules loaded with -p name or -pname. It skips -p no:name, which disables a plugin. Every pytest test file depends on each plugin that resolves in the repository, against the same roots as an absolute import. A first-party plugin that does not resolve adds the blocker Unresolved pytest plugin in addopts: -p <name>. A third-party plugin (-p pytest_cov) is ignored, like a third-party import.

A triple-quoted pyproject.toml value would match the current regex as an empty string, so it now marks the key unreadable, and the analysis falls back.

Validation:

  • tests/repo/python-addopts-plugins.test.ts covers settings, graph edges, the blocker and an end-to-end run (skipped without Python). It fails on main and passes here.
  • npm run typecheck, npm test (1171 pass), npm run audit:boundary.

Unsupported: the PYTEST_ADDOPTS environment variable and -p passed on the CI command line are not visible to the analysis.

readPytestSettings never read addopts, so a first-party plugin loaded with `addopts = -p myplugin` had no importer in the graph and a change to it selected no tests. Every test now depends on each -p plugin that resolves in the repository; an unresolved first-party plugin falls back. A triple-quoted pyproject.toml value, which the reader would take as an empty string, now marks the key unreadable.

Signed-off-by: FredApps <[email protected]>
…g back

A triple-quoted addopts (or other key) in pyproject.toml now has its
contents read, so a repository with a multi-line addopts keeps selective
runs. Only an unterminated multi-line string still makes the analysis
fall back.

Signed-off-by: FredApps <[email protected]>

@FredApps FredApps left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cross-review of 30e948e, plus the follow-ups below.

Checked:

  • -p name, -pname and -p no:name are parsed as pytest does. Every test gets an edge to a first-party plugin. An unresolved first-party plugin is a blocker. A third-party plugin such as pytest_cov is ignored.
  • The new tests fail with src/ reverted (0 of 4) and pass with the fix. tests/repo/python-addopts-plugins.test.ts is listed in release-files.json. Commits are DCO-signed. The branch is level with main.

Fixed:

  • 9ba0f62: the commit treated any triple-quoted string in pyproject.toml as unreadable, which is a global blocker. Before this PR addopts was not read at all. So a repository with a multi-line addopts = """...""" (common, and often with no -p in it) would have gone from selective runs to a full fallback on every change. The contents of """ and ''' strings are now read, and a basic string's line-ending backslash is joined. Only an unterminated multi-line string still falls back. The test covers basic, literal, no-plugin and unterminated strings. The updated assertions fail against 30e948e (1 of 4).
  • 9d8f6ae: removes a stray node_modules link that 9ba0f62 committed by mistake. The branch diff against main is back to the three intended files.

Still open: none. CI is green on 9d8f6ae. typecheck and audit:boundary pass locally, and the Python tests pass (10 of 10).

…ffCI#205, DiffCI#209 and DiffCI#257

The manifest is an unordered set, and the PRs listed above add their entries at the same line. Moving this entry one line away lets them merge in either order without a conflict.

Signed-off-by: FredApps <[email protected]>
FredApps added a commit to FredApps/core that referenced this pull request Nov 18, 2026
…ffCI#205, DiffCI#207 and DiffCI#257

The manifest is an unordered set, and the PRs listed above add their entries at the same line. Moving this entry one line away lets them merge in either order without a conflict.

Signed-off-by: FredApps <[email protected]>
FredApps added a commit to FredApps/core that referenced this pull request Nov 18, 2026
…ffCI#205, DiffCI#207 and DiffCI#209

The manifest is an unordered set, and the PRs listed above add their entries at the same line. Moving this entry one line away lets them merge in either order without a conflict.

Signed-off-by: FredApps <[email protected]>
@FredApps
FredApps marked this pull request as ready for review November 18, 2026 01:12
@adityankale190895
adityankale190895 merged commit 50be40f into DiffCI:main Nov 18, 2026
13 checks passed
adityankale190895 pushed a commit that referenced this pull request Nov 18, 2026
* fix(python): expand wildcards in pytest testpaths

pytest expands each testpaths entry with glob.iglob(entry, recursive=True). isPytestFile compared entries as literal directory prefixes, so with testpaths = ["tests", "pkgs/*/tests"] the tests under pkgs/*/tests were not test files, and a change they cover selected nothing.

Signed-off-by: FredApps <[email protected]>

* chore: move the release-files.json entry so it merges cleanly with #205, #207 and #257

The manifest is an unordered set, and the PRs listed above add their entries at the same line. Moving this entry one line away lets them merge in either order without a conflict.

Signed-off-by: FredApps <[email protected]>

---------

Signed-off-by: FredApps <[email protected]>
adityankale190895 pushed a commit that referenced this pull request Nov 18, 2026
…rs (#257)

* fix(impact): treat modelled Python files as code when resolving readers

resolveByReference passed isSourceFilePath as isCodeFile, which does not include .py. A pytest test that reads a changed data file was therefore followed as a script; nothing names a test file, so the change selected no tests and did not fall back. Python files the adapter modelled now count as code, so the reading test is selected, and a helper that reads the file selects the tests that import it.

Signed-off-by: FredApps <[email protected]>

* chore: move the release-files.json entry so it merges cleanly with #205, #207 and #209

The manifest is an unordered set, and the PRs listed above add their entries at the same line. Moving this entry one line away lets them merge in either order without a conflict.

Signed-off-by: FredApps <[email protected]>

* ci: re-run checks after the fuzz-timing flake (#300, fixed by #302)

Signed-off-by: FredApps <[email protected]>

---------

Signed-off-by: FredApps <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: plugins loaded with -p in pytest addopts are not in the graph

2 participants