From 2d995d2a4bb59d6e09610115740a9da2bc3d0c36 Mon Sep 17 00:00:00 2001 From: Thomas Wimmer Date: Sun, 4 Feb 2024 09:19:59 +0100 Subject: [PATCH] Remove _importconftest call on pytest>=8 The _importconftest call is no longer needed in the collect method of the SphinxDoctestModule class according to #58. Therefore, it is removed in this commit. Closes #58 --- src/pytest_sphinx.py | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/pytest_sphinx.py b/src/pytest_sphinx.py index 5708e0f..a668358 100644 --- a/src/pytest_sphinx.py +++ b/src/pytest_sphinx.py @@ -556,20 +556,13 @@ def collect(self) -> Iterator[_pytest.doctest.DoctestItem]: class SphinxDoctestModule(pytest.Module): def collect(self) -> Iterator[_pytest.doctest.DoctestItem]: - if self.fspath.basename == "conftest.py": - module = self.config.pluginmanager._importconftest( - self.path, - self.config.getoption("importmode"), - rootpath=self.config.rootpath, - ) - else: - try: - module = import_path(self.path, root=self.config.rootpath) - except ImportError: - if self.config.getvalue("doctest_ignore_import_errors"): - pytest.skip("unable to import module %r" % self.path) - else: - raise + try: + module = import_path(self.path, root=self.config.rootpath) + except ImportError: + if self.config.getvalue("doctest_ignore_import_errors"): + pytest.skip("unable to import module %r" % self.path) + else: + raise optionflags = _pytest.doctest.get_optionflags(self.config) # type:ignore class MockAwareDocTestFinder(doctest.DocTestFinder):