Mercurial > hg
comparison tests/run-tests.py @ 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 |
comparison
equal
deleted
inserted
replaced
21429:203ed3cf6c81 | 21430:cf2992656bf8 |
---|---|
987 # Don't worry too much about accessing the non-public _TextTestResult. | 987 # Don't worry too much about accessing the non-public _TextTestResult. |
988 # It is relatively common in Python testing tools. | 988 # It is relatively common in Python testing tools. |
989 def __init__(self, *args, **kwargs): | 989 def __init__(self, *args, **kwargs): |
990 super(TestResult, self).__init__(*args, **kwargs) | 990 super(TestResult, self).__init__(*args, **kwargs) |
991 | 991 |
992 # unittest.TestResult didn't have skipped until 2.7. We need to | |
993 # polyfill it. | |
994 self.skipped = [] | |
995 | |
996 # Polyfill. | |
997 def addSkip(self, test, reason): | |
998 self.skipped.append((test, reason)) | |
999 | |
1000 if self.showAll: | |
1001 self.stream.writeln('skipped %s' % reason) | |
1002 else: | |
1003 self.stream.write('s') | |
1004 self.stream.flush() | |
1005 | |
992 class TextTestRunner(unittest.TextTestRunner): | 1006 class TextTestRunner(unittest.TextTestRunner): |
993 """Custom unittest test runner that uses appropriate settings.""" | 1007 """Custom unittest test runner that uses appropriate settings.""" |
994 | 1008 |
995 def _makeResult(self): | 1009 def _makeResult(self): |
996 return TestResult(self.stream, self.descriptions, self.verbosity) | 1010 return TestResult(self.stream, self.descriptions, self.verbosity) |
1287 elif code == '~': | 1301 elif code == '~': |
1288 pass | 1302 pass |
1289 elif code == '.': | 1303 elif code == '.': |
1290 pass | 1304 pass |
1291 elif code == 's': | 1305 elif code == 's': |
1292 pass | 1306 self._result.addSkip(self, msg) |
1293 elif code == 'i': | 1307 elif code == 'i': |
1294 pass | 1308 pass |
1295 else: | 1309 else: |
1296 self.fail('Unknown test result code: %s' % code) | 1310 self.fail('Unknown test result code: %s' % code) |
1297 | 1311 |