run-tests: teach unittest about skipped tests
authorGregory Szorc <gregory.szorc@gmail.com>
Sun, 20 Apr 2014 11:48:19 -0700
changeset 21430 cf2992656bf8
parent 21429 203ed3cf6c81
child 21431 0f12bc8aed80
run-tests: teach unittest about skipped tests
tests/run-tests.py
--- a/tests/run-tests.py	Sun Apr 20 11:47:40 2014 -0700
+++ b/tests/run-tests.py	Sun Apr 20 11:48:19 2014 -0700
@@ -989,6 +989,20 @@
     def __init__(self, *args, **kwargs):
         super(TestResult, self).__init__(*args, **kwargs)
 
+        # unittest.TestResult didn't have skipped until 2.7. We need to
+        # polyfill it.
+        self.skipped = []
+
+    # Polyfill.
+    def addSkip(self, test, reason):
+        self.skipped.append((test, reason))
+
+        if self.showAll:
+            self.stream.writeln('skipped %s' % reason)
+        else:
+            self.stream.write('s')
+            self.stream.flush()
+
 class TextTestRunner(unittest.TextTestRunner):
     """Custom unittest test runner that uses appropriate settings."""
 
@@ -1289,7 +1303,7 @@
                 elif code == '.':
                     pass
                 elif code == 's':
-                    pass
+                    self._result.addSkip(self, msg)
                 elif code == 'i':
                     pass
                 else: