diff --git a/_pytest/hookspec.py b/_pytest/hookspec.py index 99ae77d55..a3f79fd01 100644 --- a/_pytest/hookspec.py +++ b/_pytest/hookspec.py @@ -107,12 +107,6 @@ pytest_pycollect_makemodule.firstresult = True def pytest_pycollect_onmodule(mod): """ 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): """ return custom item/collector for a python object in a module, or None. """ pytest_pycollect_makeitem.firstresult = True diff --git a/_pytest/python.py b/_pytest/python.py index 9402d93d0..2b47476c9 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -228,13 +228,9 @@ class Module(pytest.File, PyCollectorMixin): return self._memoizedcall('_obj', self._importtestmodule) def _importtestmodule(self): - self.ihook.pytest_pycollect_before_module_import(mod=self) # we assume we are only called once per module try: - try: - mod = self.fspath.pyimport(ensuresyspath=True) - finally: - self.ihook.pytest_pycollect_after_module_import(mod=self) + mod = self.fspath.pyimport(ensuresyspath=True) except SyntaxError: excinfo = py.code.ExceptionInfo() raise self.CollectError(excinfo.getrepr(style="short"))