no key error subsequent to test module import error
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 04 Mar 2010 17:51:19 +0100
changeset 4804 daa71eaf11e8
parent 4797 c8d5fcc3d64a
child 4808 23df4a120c96
no key error subsequent to test module import error
pytestconf.py
--- a/pytestconf.py	Thu Mar 04 12:08:23 2010 +0100
+++ b/pytestconf.py	Thu Mar 04 17:51:19 2010 +0100
@@ -13,7 +13,12 @@
             return super(CustomPyTester, self).testfile(filename, batchmode)
         finally:
             modname = splitext(split(filename)[1])[0]
-            for cls in vars(sys.modules[modname]).values():
+            try:
+                module = sys.modules[modname]
+            except KeyError:
+                # error during test module import
+                return
+            for cls in vars(module).values():
                 if getattr(cls, '__module__', None) != modname:
                     continue
                 clean_repo_test_cls(cls)