Skip to content

fix(python): pytest.ini wins even when empty, and read .pytest.ini - #314

Merged
adityankale190895 merged 1 commit into
DiffCI:mainfrom
sarankumar1325:fix/pytest-ini-precedence
Nov 18, 2026
Merged

adityankale190895 merged 1 commit into
DiffCI:mainfrom
sarankumar1325:fix/pytest-ini-precedence

Conversation

@sarankumar1325

Copy link
Copy Markdown
Contributor

Closes #159

pytest's rule is that pytest.ini "will always match and take precedence … even if empty", and the hidden .pytest.ini behaves the same way. Only pyproject.toml, tox.ini and setup.cfg need their section to match. readPytestSettings skipped any file without its section and never read .pytest.ini.

Changes:

  • The search order is now pytest.ini, .pytest.ini, pyproject.toml, tox.ini, setup.cfg.
  • If pytest.ini or .pytest.ini exists, the search stops there, with or without a [pytest] section. pytest's defaults (test_*.py, *_test.py) apply when there is no section.
  • .pytest.ini is in PROJECT_FILES, so a repository whose only pytest file is .pytest.ini is detected as a Python project. The docs list that names the project files includes it too.
  • The CONFIG_PATTERNS entry is now ^\.?pytest\.ini$, so a change to .pytest.ini falls back with the same named reason as pytest.ini.

Tests in tests/repo/python-adapter.test.ts, covering both cases from the issue plus:

  • a comment-only pytest.ini plus a pyproject.toml that sets check_*.py gives the defaults, so test_x.py is a test and check_x.py is not;
  • an empty pytest.ini stops the search before tox.ini;
  • a .pytest.ini that sets python_files = check_*.py is read; pytest.ini beats .pytest.ini, and an empty .pytest.ini beats pyproject.toml;
  • a repo with only .pytest.ini is detected.

Mutation check: with the src/ changes reverted, 4 of the new cases fail.

npm test (1243 pass, 0 fail), npm run typecheck and npm run audit:boundary pass. DCO signed off.

pytest.ini and .pytest.ini match even without a [pytest] section, and
then pytest uses its defaults; only pyproject.toml, tox.ini and setup.cfg
need their section. readPytestSettings skipped a section-less pytest.ini
and never read .pytest.ini. Closes DiffCI#159.

Signed-off-by: sarankumar1325 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T04:22:46.146666Z a8b8586 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@adityankale190895
adityankale190895 merged commit db0166f into DiffCI:main Nov 18, 2026
13 checks passed
adityankale190895 added a commit that referenced this pull request Nov 18, 2026
Credit the pytest configuration fixes (#314, #315, #316) under the
Python fallback reasons, and the pytest declared-inputs example (#319)
next to the example.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: adityankale190895 <[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.

pytest.ini wins even when it's empty, and .pytest.ini is never read

2 participants