Implement discover import error detection on 2.6.
authorRobert Collins <robertc@robertcollins.net>
Wed, 27 Aug 2014 20:17:52 +0000 (08:17 +1200)
committerRobert Collins <robertc@robertcollins.net>
Thu, 28 Aug 2014 09:34:09 +0000 (21:34 +1200)
Change-Id: I619a3cfa671ba4f1c0b4450c3a297046ec70bff1

NEWS
testtools/run.py

diff --git a/NEWS b/NEWS
index e82e383b5b9778af547b87ba6ad3590b40519886..8c9c40539c2b6b0510fdd0a0a1136fb0498f1752 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,12 @@ Changes and improvements to testtools_, grouped by release.
 NEXT
 ~~~~
 
+Improvements
+------------
+
+* Discovery import error detection wasn't implemented for python 2.6 (the
+  'discover' module). (Robert Collins)
+
 0.9.37
 ~~~~~~
 
index a8e1685d5deed6759f8654f6a370b7f958055466..eee179a1c84cf6b5478a963b9f5bf1cb17746cbb 100755 (executable)
@@ -48,13 +48,17 @@ def list_test(test):
     :return: A tuple of test ids that would run and error strings
         describing things that failed to import.
     """
-    unittest_import_str = 'unittest.loader.ModuleImportFailure.' 
+    unittest_import_strs = set([
+        'unittest.loader.ModuleImportFailure.', 'discover.ModuleImportFailure.'
+        ])
     test_ids = []
     errors = []
     for test in iterate_tests(test):
-        # to this ugly.
-        if test.id().startswith(unittest_import_str):
-            errors.append(test.id()[len(unittest_import_str):])
+        # Much ugly.
+        for prefix in unittest_import_strs:
+            if test.id().startswith(prefix):
+                errors.append(test.id()[len(prefix):])
+                break
         else:
             test_ids.append(test.id())
     return test_ids, errors