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