diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2021-08-31 17:45:09 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-31 17:45:09 (GMT) |
commit | 2b76a5322fdf71d62b531fd765085f96f981c244 (patch) | |
tree | 0f7d65f639871c6c44605d7f0ce7325e4b83ecc7 /Lib/test | |
parent | 70ccee418d1f9d34ed15cfe7104221f9cfd27d03 (diff) | |
download | cpython-2b76a5322fdf71d62b531fd765085f96f981c244.zip cpython-2b76a5322fdf71d62b531fd765085f96f981c244.tar.gz cpython-2b76a5322fdf71d62b531fd765085f96f981c244.tar.bz2 |
bpo-45057: Simplify RegressionTestResult (GH-28081)
Remove code which duplicates the functionality of TextTestResult.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/support/testresult.py | 33 |
1 files changed, 2 insertions, 31 deletions
diff --git a/Lib/test/support/testresult.py b/Lib/test/support/testresult.py index 670afbe..6f2edda 100644 --- a/Lib/test/support/testresult.py +++ b/Lib/test/support/testresult.py @@ -10,12 +10,11 @@ import traceback import unittest class RegressionTestResult(unittest.TextTestResult): - separator1 = '=' * 70 + '\n' - separator2 = '-' * 70 + '\n' USE_XML = False def __init__(self, stream, descriptions, verbosity): - super().__init__(stream=stream, descriptions=descriptions, verbosity=0) + super().__init__(stream=stream, descriptions=descriptions, + verbosity=2 if verbosity else 0) self.buffer = True if self.USE_XML: from xml.etree import ElementTree as ET @@ -25,8 +24,6 @@ class RegressionTestResult(unittest.TextTestResult): self.__suite.set('start', datetime.utcnow().isoformat(' ')) self.__e = None self.__start_time = None - self.__results = [] - self.__verbose = bool(verbosity) @classmethod def __getId(cls, test): @@ -45,9 +42,6 @@ class RegressionTestResult(unittest.TextTestResult): if self.USE_XML: self.__e = e = self.__ET.SubElement(self.__suite, 'testcase') self.__start_time = time.perf_counter() - if self.__verbose: - self.stream.write(f'{self.getDescription(test)} ... ') - self.stream.flush() def _add_result(self, test, capture=False, **args): if not self.USE_XML: @@ -85,10 +79,6 @@ class RegressionTestResult(unittest.TextTestResult): else: e2.text = str(v) - def __write(self, c, word): - if self.__verbose: - self.stream.write(f'{word}\n') - @classmethod def __makeErrorDict(cls, err_type, err_value, err_tb): if isinstance(err_type, type): @@ -111,45 +101,26 @@ class RegressionTestResult(unittest.TextTestResult): def addError(self, test, err): self._add_result(test, True, error=self.__makeErrorDict(*err)) super().addError(test, err) - self.__write('E', 'ERROR') def addExpectedFailure(self, test, err): self._add_result(test, True, output=self.__makeErrorDict(*err)) super().addExpectedFailure(test, err) - self.__write('x', 'expected failure') def addFailure(self, test, err): self._add_result(test, True, failure=self.__makeErrorDict(*err)) super().addFailure(test, err) - self.__write('F', 'FAIL') def addSkip(self, test, reason): self._add_result(test, skipped=reason) super().addSkip(test, reason) - self.__write('S', f'skipped {reason!r}') def addSuccess(self, test): self._add_result(test) super().addSuccess(test) - self.__write('.', 'ok') def addUnexpectedSuccess(self, test): self._add_result(test, outcome='UNEXPECTED_SUCCESS') super().addUnexpectedSuccess(test) - self.__write('u', 'unexpected success') - - def printErrors(self): - if self.__verbose: - self.stream.write('\n') - self.printErrorList('ERROR', self.errors) - self.printErrorList('FAIL', self.failures) - - def printErrorList(self, flavor, errors): - for test, err in errors: - self.stream.write(self.separator1) - self.stream.write(f'{flavor}: {self.getDescription(test)}\n') - self.stream.write(self.separator2) - self.stream.write('%s\n' % err) def get_xml_element(self): if not self.USE_XML: |