comparison tests/run-tests.py @ 21431:0f12bc8aed80

run-tests: teach unittest about ignored tests
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 20 Apr 2014 11:51:11 -0700
parents cf2992656bf8
children 1a46f9635ef0
comparison
equal deleted inserted replaced
21430:cf2992656bf8 21431:0f12bc8aed80
991 991
992 # unittest.TestResult didn't have skipped until 2.7. We need to 992 # unittest.TestResult didn't have skipped until 2.7. We need to
993 # polyfill it. 993 # polyfill it.
994 self.skipped = [] 994 self.skipped = []
995 995
996 # We have a custom "ignored" result that isn't present in any Python
997 # unittest implementation. It is very similar to skipped. It may make
998 # sense to map it into skip some day.
999 self.ignored = []
1000
996 # Polyfill. 1001 # Polyfill.
997 def addSkip(self, test, reason): 1002 def addSkip(self, test, reason):
998 self.skipped.append((test, reason)) 1003 self.skipped.append((test, reason))
999 1004
1000 if self.showAll: 1005 if self.showAll:
1001 self.stream.writeln('skipped %s' % reason) 1006 self.stream.writeln('skipped %s' % reason)
1002 else: 1007 else:
1003 self.stream.write('s') 1008 self.stream.write('s')
1009 self.stream.flush()
1010
1011 def addIgnore(self, test, reason):
1012 self.ignored.append((test, reason))
1013
1014 if self.showAll:
1015 self.stream.writeln('ignored %s' % reason)
1016 else:
1017 self.stream.write('i')
1004 self.stream.flush() 1018 self.stream.flush()
1005 1019
1006 class TextTestRunner(unittest.TextTestRunner): 1020 class TextTestRunner(unittest.TextTestRunner):
1007 """Custom unittest test runner that uses appropriate settings.""" 1021 """Custom unittest test runner that uses appropriate settings."""
1008 1022
1303 elif code == '.': 1317 elif code == '.':
1304 pass 1318 pass
1305 elif code == 's': 1319 elif code == 's':
1306 self._result.addSkip(self, msg) 1320 self._result.addSkip(self, msg)
1307 elif code == 'i': 1321 elif code == 'i':
1308 pass 1322 self._result.addIgnore(self, msg)
1309 else: 1323 else:
1310 self.fail('Unknown test result code: %s' % code) 1324 self.fail('Unknown test result code: %s' % code)
1311 1325
1312 return MercurialTest(test) 1326 return MercurialTest(test)
1313 1327