Introduce --import-mode=importlib (#7246)
Fix #5821 Co-authored-by: Ran Benita <ran@unusedvar.com>
This commit is contained in:
@@ -33,6 +33,7 @@ from _pytest.config import Config
|
||||
from _pytest.config.argparsing import Parser
|
||||
from _pytest.fixtures import FixtureRequest
|
||||
from _pytest.outcomes import OutcomeException
|
||||
from _pytest.pathlib import import_path
|
||||
from _pytest.python_api import approx
|
||||
from _pytest.warning_types import PytestWarning
|
||||
|
||||
@@ -530,10 +531,12 @@ class DoctestModule(pytest.Module):
|
||||
)
|
||||
|
||||
if self.fspath.basename == "conftest.py":
|
||||
module = self.config.pluginmanager._importconftest(self.fspath)
|
||||
module = self.config.pluginmanager._importconftest(
|
||||
self.fspath, self.config.getoption("importmode")
|
||||
)
|
||||
else:
|
||||
try:
|
||||
module = self.fspath.pyimport()
|
||||
module = import_path(self.fspath)
|
||||
except ImportError:
|
||||
if self.config.getvalue("doctest_ignore_import_errors"):
|
||||
pytest.skip("unable to import module %r" % self.fspath)
|
||||
|
||||
Reference in New Issue
Block a user