changeset 21430:cf2992656bf8

run-tests: teach unittest about skipped tests
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 20 Apr 2014 11:48:19 -0700
parents 203ed3cf6c81
children 0f12bc8aed80
files tests/run-tests.py
diffstat 1 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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: