wireshark/debian/patches/0001-tests-Get-tests-workin...

46 lines
1.8 KiB
Diff

From fdc335e68654db8c47f98ab46598d8d4e5a655b9 Mon Sep 17 00:00:00 2001
From: John Thacker <johnthacker@gmail.com>
Date: Wed, 28 Dec 2022 00:14:35 -0500
Subject: [PATCH] tests: Get tests working with Python 3.11 (except with
pytest)
We use a common idiom ( https://stackoverflow.com/a/39606065
https://gist.github.com/hynekcer/1b0a260ef72dae05fe9611904d7b9675 )
for getting the results of our unittest.TestCases in the tearDown
method. This method accesses a private property, and that private
property was removed in Python 3.11
The StackOverflow answer has been updated with a new approach for
Python 3.11, which also uses a private property. This fixes things
for CTest (and the test target when building), but it still doesn't
work when using pytest's unittest support.
Ping #18740
---
test/subprocesstest.py | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/test/subprocesstest.py b/test/subprocesstest.py
index a3a27d33f6..02422a6cba 100644
--- a/test/subprocesstest.py
+++ b/test/subprocesstest.py
@@ -165,7 +165,14 @@ class SubprocessTestCase(unittest.TestCase):
# It remains None when running in debug mode (`pytest --pdb`).
# The property is available since Python 3.4 until at least Python 3.7.
if self._outcome:
- for test_case, exc_info in self._outcome.errors:
+ if hasattr(self._outcome, 'errors'):
+ # Python 3.4 - 3.10
+ result = self.defaultTestResult()
+ self._feedErrorsToResult(result, self._outcome.errors)
+ else:
+ # Python 3.11+
+ result = self._outcome.result
+ for test_case, exc_info in (result.errors + result.failures):
if exc_info:
return True
# No errors occurred or running in debug mode.
--
2.34.1