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
--- a/tests/basic_test_result.py Wed Oct 20 16:54:43 2021 +0200
+++ b/tests/basic_test_result.py Tue Oct 19 16:05:20 2021 +0200
@@ -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
--- a/tests/run-tests.py Wed Oct 20 16:54:43 2021 +0200
+++ b/tests/run-tests.py Tue Oct 19 16:05:20 2021 +0200
@@ -2233,12 +2233,15 @@
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)