[conduit: 118/138] Report which missing features caused which tests to be skipped



commit 63fef80a89007cbf0ce0a6afbcfe8c5cd0940a68
Author: John Carr <john carr unrouted co uk>
Date:   Wed May 6 09:22:30 2009 -0700

    Report which missing features caused which tests to be skipped
---
 test/soup/__init__.py     |    2 +-
 test/soup/modules/ipod.py |    4 +---
 test/soup/utils/test.py   |   15 ++++++++++++++-
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/test/soup/__init__.py b/test/soup/__init__.py
index ceb21c1..d7c54c4 100644
--- a/test/soup/__init__.py
+++ b/test/soup/__init__.py
@@ -173,7 +173,7 @@ class Feature(object):
 
     def require(self):
         if not self.available():
-            raise UnavailableFeature
+            raise UnavailableFeature(self)
 
     @classmethod
     def name(cls):
diff --git a/test/soup/modules/ipod.py b/test/soup/modules/ipod.py
index 61edf83..6cea3e3 100644
--- a/test/soup/modules/ipod.py
+++ b/test/soup/modules/ipod.py
@@ -18,10 +18,8 @@ import shutil
 class _GpodModule(soup.Feature):
 
     def probe(self):
-        import pdb
-        pdb.set_trace()
         try:
-            import gpod
+            import gpodmonkey
             return True
         except:
             return False
diff --git a/test/soup/utils/test.py b/test/soup/utils/test.py
index 2ebec6c..b73fde2 100644
--- a/test/soup/utils/test.py
+++ b/test/soup/utils/test.py
@@ -18,6 +18,7 @@ class TestResult(unittest.TestResult):
         self.descriptions = descriptions
         self.verbosity = verbosity
         self.num_tests = num_tests
+        self.unsupported = {}
 
     def startTest(self, test):
         super(TestResult, self).startTest(test)
@@ -29,7 +30,7 @@ class TestResult(unittest.TestResult):
 
     def addError(self, test, err):
         if isinstance(err[1], UnavailableFeature):
-            self.addSkipped(test)
+            self.addUnsupported(test, err[1].args[0])
         else:
             super(TestResult, self).addError(test, err)
             self.report_error(test)
@@ -38,6 +39,11 @@ class TestResult(unittest.TestResult):
         super(TestResult, self).addFailure(test, err)
         self.report_failure(test)
 
+    def addUnsupported(self, test, feature):
+        self.unsupported.setdefault(str(feature), 0)
+        self.unsupported[str(feature)] += 1
+        self.report_unsupported(test, feature)
+
     def addSkipped(self, test):
         self.report_skipped(test)
 
@@ -74,6 +80,9 @@ class TestResult(unittest.TestResult):
     def report_failure(self, test):
         pass
 
+    def report_unsupported(self, test, feature):
+        pass
+
     def report_skipped(self, test):
         pass
 
@@ -115,6 +124,10 @@ class TextTestResult(TestResult):
         else:
             self.stream.writeln("OK")
 
+        if len(self.unsupported) > 0:
+            for feature, count in self.unsupported.iteritems():
+                self.stream.writeln("Feature '%s' not available, %d tests skipped" % (feature, count))
+
     def printErrorList(self, flavour, errors):
         for test, err in errors:
             self.stream.writeln(self.seperator1)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]