Skip to content

Make xdoctest pytest items safe for embedding - #214

Merged
Erotemic merged 1 commit into
mainfrom
review/05-pytest-embedding
Jul 14, 2026
Merged

Make xdoctest pytest items safe for embedding#214
Erotemic merged 1 commit into
mainfrom
review/05-pytest-embedding

Conversation

@Erotemic

@Erotemic Erotemic commented Jul 12, 2026

Copy link
Copy Markdown
Owner

What changed

  • Allows XDoctestItem to be embedded when the optional xdoctest_namespace fixture is not registered.
  • Preserves real fixture dependency failures instead of swallowing every FixtureLookupError.
  • Defers .rst and .txt collection only when the active pytest-doctestplus collector actually owns the path through pytest's standard doctest globs.
  • Rebuilds the PR directly on current main, excluding stale checker-lifecycle and module-metadata implementations inherited by the old stacked branch.
  • Keeps the embedding tests executable across the pytest 6 / Python 3.8 and current-pytest lanes.

Pytest compatibility corrections

  • The embedded collector resolves path on modern pytest and falls back to legacy fspath instead of assuming either API or using a platform-sensitive relative filename.
  • The text-file ownership unit test passes pytest's real legacy py.path type on pytest 6 and pathlib.Path on pytest 7+, matching the production hook boundary.
  • Runtime annotations in the tests remain Python 3.8-safe.

Skip behavior

Current main already contains the accepted #213 behavior: DocTest.run() reports full skips with the most concrete metadata reason, and XDoctestItem.runtest() retains the empty-run fallback. This PR deliberately leaves that centralized behavior unchanged rather than adding a second skip path.

Validation

  • The complete pytest embedding/coexistence group passes in the available environment; the real pytest-doctestplus case skips when that package is absent.

  • An explicit legacy pytest ownership probe exercises the py.path.check(fnmatch=...) branch.

  • The publisher runs the complete embedding group under python3.8 when available.

  • The publisher requires mypy src/xdoctest, ty check src/xdoctest tests/, fatal flake8 selectors, and git diff --check before publication.

  • Uses a real PathLike argument for legacy py.path.local.join, satisfying both pytest 6 runtime behavior and current ty stubs.

@Erotemic
Erotemic force-pushed the review/04-module-metadata-hardening branch from c8271cd to b8836d0 Compare July 12, 2026 00:38
@Erotemic
Erotemic force-pushed the review/05-pytest-embedding branch 2 times, most recently from 481f725 to e2f2e0c Compare July 12, 2026 03:44
@Erotemic
Erotemic force-pushed the review/04-module-metadata-hardening branch 2 times, most recently from cf330ce to 30238a1 Compare July 13, 2026 01:18
@Erotemic
Erotemic force-pushed the review/05-pytest-embedding branch from e2f2e0c to c7fc48a Compare July 13, 2026 03:17
@Erotemic
Erotemic changed the base branch from review/04-module-metadata-hardening to main July 13, 2026 03:17
@Erotemic
Erotemic marked this pull request as ready for review July 13, 2026 03:17
@Erotemic
Erotemic force-pushed the review/05-pytest-embedding branch 2 times, most recently from 451b25d to 9fa8518 Compare July 13, 2026 03:43
Tolerate an absent optional namespace fixture without hiding dependency failures, and defer text files only to the active pytest-doctestplus owner that matches them.

Co-authored-by: GPT-5.6 High <noreply@openai.com>
@Erotemic
Erotemic force-pushed the review/05-pytest-embedding branch from 9fa8518 to 68e79bc Compare July 13, 2026 14:48
@Erotemic
Erotemic merged commit e81aea9 into main Jul 14, 2026
80 checks passed
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.

1 participant