# HG changeset patch # User Raphaël Gomès # Date 2021-10-19 14:05:20 # Node ID 3a95a4e660b99beccdd5663537404e966ca96267 # Parent f6b045910d82d55b13a5212d10379a31f6047688 python: compatibility for python 3.11 (issue6604) The `unittest._TextTestResult` alias has been removed. The "new" name has been available since 3.2, and we only support 3.5.3+. Differential Revision: https://phab.mercurial-scm.org/D11690 diff --git a/tests/basic_test_result.py b/tests/basic_test_result.py --- a/tests/basic_test_result.py +++ b/tests/basic_test_result.py @@ -1,9 +1,15 @@ from __future__ import absolute_import, print_function +import sys import unittest +if sys.version_info[0] < 3: + base_class = unittest._TextTestResult +else: + base_class = unittest.TextTestResult -class TestResult(unittest._TextTestResult): + +class TestResult(base_class): def __init__(self, options, *args, **kwargs): super(TestResult, self).__init__(*args, **kwargs) self._options = options diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -2233,12 +2233,15 @@ iolock = threading.RLock() firstlock = threading.RLock() firsterror = False - -class TestResult(unittest._TextTestResult): +if PYTHON3: + base_class = unittest.TextTestResult +else: + base_class = unittest._TextTestResult + + +class TestResult(base_class): """Holds results when executing via unittest.""" - # Don't worry too much about accessing the non-public _TextTestResult. - # It is relatively common in Python testing tools. def __init__(self, options, *args, **kwargs): super(TestResult, self).__init__(*args, **kwargs)