From e02d22aa4f0ebb768f93b939b67853ad3d9c2087 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Wed, 25 May 2011 15:55:57 -0500 Subject: [PATCH] expand try/except/finally which py2.4 does't like --- _pytest/python.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/_pytest/python.py b/_pytest/python.py index e2aa5a754..7a01b62fc 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -228,7 +228,10 @@ class Module(pytest.File, PyCollectorMixin): self.ihook.pytest_pycollect_before_module_import(mod=self) # we assume we are only called once per module try: - mod = self.fspath.pyimport(ensuresyspath=True) + try: + mod = self.fspath.pyimport(ensuresyspath=True) + finally: + self.ihook.pytest_pycollect_after_module_import(mod=self) except SyntaxError: excinfo = py.code.ExceptionInfo() raise self.CollectError(excinfo.getrepr(style="short")) @@ -243,8 +246,6 @@ class Module(pytest.File, PyCollectorMixin): "HINT: use a unique basename for your test file modules" % e.args ) - finally: - self.ihook.pytest_pycollect_after_module_import(mod=self) #print "imported test module", mod self.config.pluginmanager.consider_module(mod) return mod