File gevent-fix-unittest-returncode-py312-c2.patch of Package python-gevent

From f69bc6b872b81a3dbc704c83147822fd7009995d Mon Sep 17 00:00:00 2001
From: Jason Madden <jamadden@gmail.com>
Date: Wed, 13 Dec 2023 15:01:10 -0600
Subject: [PATCH] No, really allow unittest on Py 3.12.1 to have skipped tests.

---
 src/gevent/testing/testrunner.py |  1 +
 src/gevent/testing/util.py       | 14 ++++++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/gevent/testing/testrunner.py b/src/gevent/testing/testrunner.py
index 37f5aee49..1704b77a3 100644
--- a/src/gevent/testing/testrunner.py
+++ b/src/gevent/testing/testrunner.py
@@ -161,6 +161,7 @@ def __init__(self,
         self._allowed_return_codes = allowed_return_codes
 
     def _run_one(self, cmd, **kwargs):
+        kwargs['allowed_return_codes'] = self._allowed_return_codes
         if self._quiet is not None:
             kwargs['quiet'] = self._quiet
         result = util.run(cmd, **kwargs)
diff --git a/src/gevent/testing/util.py b/src/gevent/testing/util.py
index 0ccd2035d..fa67f0c39 100644
--- a/src/gevent/testing/util.py
+++ b/src/gevent/testing/util.py
@@ -260,7 +260,6 @@ class RunResult(object):
     value of True; otherwise, a boolean value of false.
 
     The integer value of this object is the command's exit code.
-
     """
 
     def __init__(self,
@@ -394,7 +393,9 @@ def run(command, **kwargs): # pylint:disable=too-many-locals
         kill(popen)
         assert popen.timer is None
 
-
+    # We don't want to treat return codes that are allowed as failures,
+    # but we do want to log those specially. That's why we retain the distinction
+    # between ``failed`` and ``result`` (failed takes the allowed codes into account).
     failed = bool(result) and result not in allowed_return_codes
     if out:
         out = out.strip()
@@ -406,11 +407,16 @@ def run(command, **kwargs): # pylint:disable=too-many-locals
         log('| %s\n%s', name, out)
     status, run_count, skipped_count = _find_test_status(duration, out)
     if result:
-        log('! %s [code %s] %s', name, result, status, color='error')
+        log('! %s [code %s] %s', name, result, status,
+            color='error' if failed else 'suboptimal-behaviour')
     elif not nested:
         log('- %s %s', name, status)
+
+    # For everything outside this function, we need to pretend that
+    # allowed codes are actually successes.
     return RunResult(
-        command, kwargs, result,
+        command, kwargs,
+        0 if result in allowed_return_codes else result,
         output=out, error=err,
         name=name,
         run_count=run_count,
openSUSE Build Service is sponsored by