def _importtestmodule(self):
# we assume we are only called once per module
importmode = self.config.getoption("--import-mode", default=True)
try:
# XXX patch pyimport in pytest._pytest.pythod.Module
mod = _patch_pyimport(self.fspath, ensuresyspath=importmode)
except SyntaxError:
raise self.CollectError(
_pytest._code.ExceptionInfo().getrepr(style="short"))
except self.fspath.ImportMismatchError:
e = sys.exc_info()[1]
raise self.CollectError(
"import file mismatch:\n"
"imported module %r has this __file__ attribute:\n"
" %s\n"
"which is not the same as the test file we want to collect:\n"
" %s\n"
"HINT: remove __pycache__ / .pyc files and/or use a "
"unique basename for your test file modules"
% e.args
)
# print "imported test module", mod
self.config.pluginmanager.consider_module(mod)
return mod
评论列表
文章目录