Show More
@@ -1046,9 +1046,11 b' class TestResult(unittest._TextTestResul' | |||||
1046 | """Holds results when executing via unittest.""" |
|
1046 | """Holds results when executing via unittest.""" | |
1047 | # Don't worry too much about accessing the non-public _TextTestResult. |
|
1047 | # Don't worry too much about accessing the non-public _TextTestResult. | |
1048 | # It is relatively common in Python testing tools. |
|
1048 | # It is relatively common in Python testing tools. | |
1049 | def __init__(self, *args, **kwargs): |
|
1049 | def __init__(self, options, *args, **kwargs): | |
1050 | super(TestResult, self).__init__(*args, **kwargs) |
|
1050 | super(TestResult, self).__init__(*args, **kwargs) | |
1051 |
|
1051 | |||
|
1052 | self._options = options | |||
|
1053 | ||||
1052 | # unittest.TestResult didn't have skipped until 2.7. We need to |
|
1054 | # unittest.TestResult didn't have skipped until 2.7. We need to | |
1053 | # polyfill it. |
|
1055 | # polyfill it. | |
1054 | self.skipped = [] |
|
1056 | self.skipped = [] | |
@@ -1063,6 +1065,18 b' class TestResult(unittest._TextTestResul' | |||||
1063 | # sense to map it into fail some day. |
|
1065 | # sense to map it into fail some day. | |
1064 | self.warned = [] |
|
1066 | self.warned = [] | |
1065 |
|
1067 | |||
|
1068 | def addFailure(self, *args, **kwargs): | |||
|
1069 | super(TestResult, self).addFailure(*args, **kwargs) | |||
|
1070 | ||||
|
1071 | if self._options.first: | |||
|
1072 | self.stop() | |||
|
1073 | ||||
|
1074 | def addError(self, *args, **kwargs): | |||
|
1075 | super(TestResult, self).addError(*args, **kwargs) | |||
|
1076 | ||||
|
1077 | if self._options.first: | |||
|
1078 | self.stop() | |||
|
1079 | ||||
1066 | # Polyfill. |
|
1080 | # Polyfill. | |
1067 | def addSkip(self, test, reason): |
|
1081 | def addSkip(self, test, reason): | |
1068 | self.skipped.append((test, reason)) |
|
1082 | self.skipped.append((test, reason)) | |
@@ -1085,6 +1099,9 b' class TestResult(unittest._TextTestResul' | |||||
1085 | def addWarn(self, test, reason): |
|
1099 | def addWarn(self, test, reason): | |
1086 | self.warned.append((test, reason)) |
|
1100 | self.warned.append((test, reason)) | |
1087 |
|
1101 | |||
|
1102 | if self._options.first: | |||
|
1103 | self.stop() | |||
|
1104 | ||||
1088 | if self.showAll: |
|
1105 | if self.showAll: | |
1089 | self.stream.writeln('warned %s' % reason) |
|
1106 | self.stream.writeln('warned %s' % reason) | |
1090 | else: |
|
1107 | else: | |
@@ -1113,7 +1130,8 b' class TextTestRunner(unittest.TextTestRu' | |||||
1113 | self._runner = runner |
|
1130 | self._runner = runner | |
1114 |
|
1131 | |||
1115 | def run(self, test): |
|
1132 | def run(self, test): | |
1116 |
result = TestResult(self. |
|
1133 | result = TestResult(self._runner.options, self.stream, | |
|
1134 | self.descriptions, self.verbosity) | |||
1117 |
|
1135 | |||
1118 | test(result) |
|
1136 | test(result) | |
1119 |
|
1137 | |||
@@ -1706,6 +1724,8 b' class TestRunner(object):' | |||||
1706 | self.results[code].append((test, msg)) |
|
1724 | self.results[code].append((test, msg)) | |
1707 | if self.options.first and code not in '.si': |
|
1725 | if self.options.first and code not in '.si': | |
1708 | break |
|
1726 | break | |
|
1727 | if result and result.shouldStop: | |||
|
1728 | break | |||
1709 | except queue.Empty: |
|
1729 | except queue.Empty: | |
1710 | continue |
|
1730 | continue | |
1711 | running -= 1 |
|
1731 | running -= 1 |
General Comments 0
You need to be logged in to leave comments.
Login now