changeset 48273:3a95a4e660b9 stable

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
author Raphaël Gomès <rgomes@octobus.net>
date Tue, 19 Oct 2021 16:05:20 +0200
parents f6b045910d82
children 1ea289e34c70
files tests/basic_test_result.py tests/run-tests.py
diffstat 2 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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)