remove module before/after import hooks
This commit is contained in:
parent
abb07fc732
commit
16b4f54545
|
@ -107,12 +107,6 @@ pytest_pycollect_makemodule.firstresult = True
|
||||||
def pytest_pycollect_onmodule(mod):
|
def pytest_pycollect_onmodule(mod):
|
||||||
""" Called when a module is collected."""
|
""" Called when a module is collected."""
|
||||||
|
|
||||||
def pytest_pycollect_before_module_import(mod):
|
|
||||||
"""Called before a module is imported."""
|
|
||||||
|
|
||||||
def pytest_pycollect_after_module_import(mod):
|
|
||||||
"""Called after a module is imported."""
|
|
||||||
|
|
||||||
def pytest_pycollect_makeitem(collector, name, obj):
|
def pytest_pycollect_makeitem(collector, name, obj):
|
||||||
""" return custom item/collector for a python object in a module, or None. """
|
""" return custom item/collector for a python object in a module, or None. """
|
||||||
pytest_pycollect_makeitem.firstresult = True
|
pytest_pycollect_makeitem.firstresult = True
|
||||||
|
|
|
@ -228,13 +228,9 @@ class Module(pytest.File, PyCollectorMixin):
|
||||||
return self._memoizedcall('_obj', self._importtestmodule)
|
return self._memoizedcall('_obj', self._importtestmodule)
|
||||||
|
|
||||||
def _importtestmodule(self):
|
def _importtestmodule(self):
|
||||||
self.ihook.pytest_pycollect_before_module_import(mod=self)
|
|
||||||
# we assume we are only called once per module
|
# we assume we are only called once per module
|
||||||
try:
|
|
||||||
try:
|
try:
|
||||||
mod = self.fspath.pyimport(ensuresyspath=True)
|
mod = self.fspath.pyimport(ensuresyspath=True)
|
||||||
finally:
|
|
||||||
self.ihook.pytest_pycollect_after_module_import(mod=self)
|
|
||||||
except SyntaxError:
|
except SyntaxError:
|
||||||
excinfo = py.code.ExceptionInfo()
|
excinfo = py.code.ExceptionInfo()
|
||||||
raise self.CollectError(excinfo.getrepr(style="short"))
|
raise self.CollectError(excinfo.getrepr(style="short"))
|
||||||
|
|
Loading…
Reference in New Issue