Skip to content

Commit dc269ec

Browse files
committed
pytest_doctest_docutils(fix[collect]): Backport autouse fixtures support
Backport: pytest commit 9cd14b4ff (2024-02-06) Ref: pytest-dev/pytest@9cd14b4ff why: Autouse fixtures were not being discovered for doctest files what: - Add parsefactories() call to DocTestDocutilsFile.collect() - Ensures session fixture manager processes the doctest module - Allows autouse fixtures from conftest.py to apply to doctests
1 parent aec6702 commit dc269ec

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/pytest_doctest_docutils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,12 @@ def collect(self) -> Iterable[DoctestItem]:
306306
# Uses internal doctest module parsing mechanism.
307307
finder = DocutilsDocTestFinder()
308308

309+
# While doctests in .rst/.md files don't support fixtures directly,
310+
# we still need to pick up autouse fixtures.
311+
# Backported from pytest commit 9cd14b4ff (2024-02-06).
312+
# https://github.com/pytest-dev/pytest/commit/9cd14b4ff
313+
self.session._fixturemanager.parsefactories(self)
314+
309315
optionflags = get_optionflags(self.config)
310316

311317
runner = _get_runner(

0 commit comments

Comments
 (0)