[Python-checkins] bpo-45057: Simplify RegressionTestResult (GH-28081) (GH-28101)

serhiy-storchaka webhook-mailer at python.org
Wed Sep 1 02:45:51 EDT 2021


https://github.com/python/cpython/commit/3d56272e4ecaef9f38c1f48430364701d34b3ee4
commit: 3d56272e4ecaef9f38c1f48430364701d34b3ee4
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: serhiy-storchaka <storchaka at gmail.com>
date: 2021-09-01T09:45:46+03:00
summary:

bpo-45057: Simplify RegressionTestResult (GH-28081) (GH-28101)

Remove code which duplicates the functionality of TextTestResult.
(cherry picked from commit 2b76a5322fdf71d62b531fd765085f96f981c244)

Co-authored-by: Serhiy Storchaka <storchaka at gmail.com>

files:
M Lib/test/support/testresult.py

diff --git a/Lib/test/support/testresult.py b/Lib/test/support/testresult.py
index 670afbea2659d..6f2edda0f580a 100644
--- a/Lib/test/support/testresult.py
+++ b/Lib/test/support/testresult.py
@@ -10,12 +10,11 @@
 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 @@ def __init__(self, stream, descriptions, verbosity):
             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 @@ def startTest(self, test):
         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 @@ def _add_result(self, test, capture=False, **args):
             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 @@ def __makeErrorDict(cls, err_type, err_value, err_tb):
     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:



More information about the Python-checkins mailing list