Skip to content

Commit

Permalink
doctest: remove special conftest handling
Browse files Browse the repository at this point in the history
(Diff better viewed ignoring whitespace)

Since e1c66ab, conftest loading is
handled at the directory level before sub-nodes are collected, so there
is no need for the doctest plugin to handle it specially.

This was probably the case even before
e1c66ab, but I haven't verified this.
  • Loading branch information
bluetech committed Jan 13, 2024
1 parent 1b78de4 commit 06dbd3c
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions src/_pytest/doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,24 +558,18 @@ def _from_module(self, module, object):
else: # pragma: no cover
pass

if self.path.name == "conftest.py":
module = self.config.pluginmanager._importconftest(
try:
module = import_path(
self.path,
self.config.getoption("importmode"),
rootpath=self.config.rootpath,
root=self.config.rootpath,
mode=self.config.getoption("importmode"),
)
else:
try:
module = import_path(
self.path,
root=self.config.rootpath,
mode=self.config.getoption("importmode"),
)
except ImportError:
if self.config.getvalue("doctest_ignore_import_errors"):
skip("unable to import module %r" % self.path)
else:
raise
except ImportError:

Check warning on line 567 in src/_pytest/doctest.py

View check run for this annotation

Codecov / codecov/patch

src/_pytest/doctest.py#L567

Added line #L567 was not covered by tests
if self.config.getvalue("doctest_ignore_import_errors"):
skip("unable to import module %r" % self.path)

Check warning on line 569 in src/_pytest/doctest.py

View check run for this annotation

Codecov / codecov/patch

src/_pytest/doctest.py#L569

Added line #L569 was not covered by tests
else:
raise

Check warning on line 571 in src/_pytest/doctest.py

View check run for this annotation

Codecov / codecov/patch

src/_pytest/doctest.py#L571

Added line #L571 was not covered by tests

# Uses internal doctest module parsing mechanism.
finder = MockAwareDocTestFinder()
optionflags = get_optionflags(self.config)
Expand Down

0 comments on commit 06dbd3c

Please sign in to comment.