Mercurial > hg
comparison tests/run-tests.py @ 32932:240183a04429
tests: use unittest.SkipTest
unittest.SkipTest was introduced in Python 2.7. We previously defined
it with our own class so we could run on Python 2.6.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 03 Jun 2017 17:04:42 -0700 |
parents | bd77ac2bd23a |
children | f83b7376a300 |
comparison
equal
deleted
inserted
replaced
32931:b08431e1b062 | 32932:240183a04429 |
---|---|
709 try: | 709 try: |
710 self.runTest() | 710 self.runTest() |
711 except KeyboardInterrupt: | 711 except KeyboardInterrupt: |
712 self._aborted = True | 712 self._aborted = True |
713 raise | 713 raise |
714 except SkipTest as e: | 714 except unittest.SkipTest as e: |
715 result.addSkip(self, str(e)) | 715 result.addSkip(self, str(e)) |
716 # The base class will have already counted this as a | 716 # The base class will have already counted this as a |
717 # test we "ran", but we want to exclude skipped tests | 717 # test we "ran", but we want to exclude skipped tests |
718 # from those we count towards those run. | 718 # from those we count towards those run. |
719 result.testsRun -= 1 | 719 result.testsRun -= 1 |
787 | 787 |
788 if failed: | 788 if failed: |
789 self.fail('hg have failed checking for %s' % failed[-1]) | 789 self.fail('hg have failed checking for %s' % failed[-1]) |
790 else: | 790 else: |
791 self._skipped = True | 791 self._skipped = True |
792 raise SkipTest(missing[-1]) | 792 raise unittest.SkipTest(missing[-1]) |
793 elif ret == 'timeout': | 793 elif ret == 'timeout': |
794 self.fail('timed out') | 794 self.fail('timed out') |
795 elif ret is False: | 795 elif ret is False: |
796 raise WarnTest('no result code from test') | 796 raise WarnTest('no result code from test') |
797 elif out != self._refout: | 797 elif out != self._refout: |
845 | 845 |
846 vlog("# Ret was:", self._ret, '(%s)' % self.name) | 846 vlog("# Ret was:", self._ret, '(%s)' % self.name) |
847 | 847 |
848 def _run(self, env): | 848 def _run(self, env): |
849 # This should be implemented in child classes to run tests. | 849 # This should be implemented in child classes to run tests. |
850 raise SkipTest('unknown test type') | 850 raise unittest.SkipTest('unknown test type') |
851 | 851 |
852 def abort(self): | 852 def abort(self): |
853 """Terminate execution of this test.""" | 853 """Terminate execution of this test.""" |
854 self._aborted = True | 854 self._aborted = True |
855 | 855 |
1484 def _stringescape(s): | 1484 def _stringescape(s): |
1485 return TTest.ESCAPESUB(TTest._escapef, s) | 1485 return TTest.ESCAPESUB(TTest._escapef, s) |
1486 | 1486 |
1487 iolock = threading.RLock() | 1487 iolock = threading.RLock() |
1488 | 1488 |
1489 class SkipTest(Exception): | |
1490 """Raised to indicate that a test is to be skipped.""" | |
1491 | |
1492 class IgnoreTest(Exception): | 1489 class IgnoreTest(Exception): |
1493 """Raised to indicate that a test is to be ignored.""" | 1490 """Raised to indicate that a test is to be ignored.""" |
1494 | 1491 |
1495 class WarnTest(Exception): | 1492 class WarnTest(Exception): |
1496 """Raised to indicate that a test warned.""" | 1493 """Raised to indicate that a test warned.""" |