From 06dbd3c21ccdf1ac76e8fa264048133cb4660842 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sat, 13 Jan 2024 11:15:05 +0200 Subject: [PATCH] doctest: remove special conftest handling (Diff better viewed ignoring whitespace) Since e1c66ab0ad8eda13e5552dfc939e07d7290ecd39, 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 e1c66ab0ad8eda13e5552dfc939e07d7290ecd39, but I haven't verified this. --- src/_pytest/doctest.py | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/_pytest/doctest.py b/src/_pytest/doctest.py index a0125e93c2d..4ce32a298e8 100644 --- a/src/_pytest/doctest.py +++ b/src/_pytest/doctest.py @@ -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: + if self.config.getvalue("doctest_ignore_import_errors"): + skip("unable to import module %r" % self.path) + else: + raise + # Uses internal doctest module parsing mechanism. finder = MockAwareDocTestFinder() optionflags = get_optionflags(self.config)