rewrite test modules on import

This commit is contained in:
Benjamin Peterson
2011-06-28 21:13:12 -05:00
parent d52ff3e2b9
commit 48b76c7544
4 changed files with 210 additions and 72 deletions

View File

@@ -226,13 +226,8 @@ class Module(pytest.File, PyCollectorMixin):
def _importtestmodule(self):
# we assume we are only called once per module
from _pytest import assertion
assertion.before_module_import(self)
try:
try:
mod = self.fspath.pyimport(ensuresyspath=True)
finally:
assertion.after_module_import(self)
mod = self.fspath.pyimport(ensuresyspath=True)
except SyntaxError:
excinfo = py.code.ExceptionInfo()
raise self.CollectError(excinfo.getrepr(style="short"))