File gevent-fix-unittest-returncode-py312-c1.patch of Package python-gevent
From 86ea07e273ed7938446688cef5492d48034b7ddb Mon Sep 17 00:00:00 2001
From: Jason Madden <jamadden@gmail.com>
Date: Wed, 13 Dec 2023 14:43:29 -0600
Subject: [PATCH] Compensate for Python 3.12.1 failing unittests of all tests
are skipped.
---
.github/workflows/ci.yml | 5 ++++-
src/gevent/testing/patched_tests_setup.py | 11 +++++++++++
src/gevent/testing/testrunner.py | 17 ++++++++++++++++-
src/gevent/testing/util.py | 3 ++-
4 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 64088705d..3574ed327 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -121,7 +121,10 @@ jobs:
- name: Set coverage status
# coverage is too slow on PyPy. We can't submit it from macOS (see that action),
# so don't bother taking the speed hit there either.
- if: ${{ !startsWith(matrix.python-version, 'pypy') && startsWith(runner.os, 'Linux') }}
+ # Coverage can't run the test_interpreters.py tests because greenlet can't
+ # run there and that's how coverage is configured. Right now, we only have that
+ # on Python 3.12, so take the quick way out and nix that version too.
+ if: ${{ !startsWith(matrix.python-version, 'pypy') && !startsWith(matrix.python-version, "3.12") && startsWith(runner.os, 'Linux') }}
run: |
echo G_USE_COV=--coverage >> $GITHUB_ENV
diff --git a/src/gevent/testing/patched_tests_setup.py b/src/gevent/testing/patched_tests_setup.py
index a95f826f9..89970ac36 100644
--- a/src/gevent/testing/patched_tests_setup.py
+++ b/src/gevent/testing/patched_tests_setup.py
@@ -34,6 +34,7 @@
from .sysinfo import WIN
from .sysinfo import OSX
+from .sysinfo import LINUX
from .sysinfo import LIBUV
from .sysinfo import CFFI_BACKEND
@@ -1252,6 +1253,16 @@ def test(*args, **kwargs):
'test_socket.BasicHyperVTest.testCreateHyperVSocketAddrVmIdNotValidUUIDFailure',
]
+ if LINUX and RUNNING_ON_CI:
+ disabled_tests += [
+ # These two try to forcibly close a socket, preventing some data
+ # from reaching its destination. That works OK on some platforms, but
+ # in this set of circumstances, because of the event loop, gevent is
+ # able to send that data.
+ 'test_ssl.TestPreHandshakeClose.test_preauth_data_to_tls_client',
+ 'test_ssl.TestPreHandshakeClose.test_preauth_data_to_tls_server',
+ ]
+
if TRAVIS:
disabled_tests += [
# These tests frequently break when we try to use newer Travis CI images,
diff --git a/src/gevent/testing/testrunner.py b/src/gevent/testing/testrunner.py
index ba6220648..37f5aee49 100644
--- a/src/gevent/testing/testrunner.py
+++ b/src/gevent/testing/testrunner.py
@@ -128,6 +128,8 @@ class Runner(object):
def __init__(self,
tests,
+ *,
+ allowed_return_codes,
configured_failing_tests=(),
failfast=False,
quiet=False,
@@ -135,6 +137,9 @@ def __init__(self,
worker_count=DEFAULT_NWORKERS,
second_chance=False):
"""
+ :keyword allowed_return_codes: Return codes other than
+ 0 that are counted as a success. Needed because some versions
+ of Python give ``unittest`` weird return codes.
:keyword quiet: Set to True or False to explicitly choose. Set to
`None` to use the default, which may come from the environment variable
``GEVENTTEST_QUIET``.
@@ -153,6 +158,7 @@ def __init__(self,
self._running_jobs = []
self._worker_count = min(len(tests), worker_count) or 1
+ self._allowed_return_codes = allowed_return_codes
def _run_one(self, cmd, **kwargs):
if self._quiet is not None:
@@ -807,7 +813,7 @@ def not_set(key):
def main():
- # pylint:disable=too-many-locals,too-many-statements
+ # pylint:disable=too-many-locals,too-many-statements,too-many-branches
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--ignore')
@@ -952,12 +958,21 @@ def main():
# XXX: Add a way to force these.
print("Not running tests on pypy with c-ares; not a supported configuration")
return
+
if options.package:
# Put this directory on the path so relative imports work.
package_dir = _dir_from_package_name(options.package)
os.environ['PYTHONPATH'] = os.environ.get('PYTHONPATH', "") + os.pathsep + package_dir
+
+ allowed_return_codes = ()
+ if sys.version_info[:3] >= (3, 12, 1):
+ # unittest suddenly started failing with this return code
+ # if all tests in a module are skipped in 3.12.1.
+ allowed_return_codes += (5,)
+
runner = Runner(
tests,
+ allowed_return_codes=allowed_return_codes,
configured_failing_tests=FAILING_TESTS,
failfast=options.failfast,
quiet=options.quiet,
diff --git a/src/gevent/testing/util.py b/src/gevent/testing/util.py
index 11f5bfcb4..0ccd2035d 100644
--- a/src/gevent/testing/util.py
+++ b/src/gevent/testing/util.py
@@ -374,6 +374,7 @@ def run(command, **kwargs): # pylint:disable=too-many-locals
quiet = kwargs.pop('quiet', QUIET)
verbose = not quiet
nested = kwargs.pop('nested', False)
+ allowed_return_codes = kwargs.pop('allowed_return_codes', ())
if buffer_output:
assert 'stdout' not in kwargs and 'stderr' not in kwargs, kwargs
kwargs['stderr'] = subprocess.STDOUT
@@ -394,7 +395,7 @@ def run(command, **kwargs): # pylint:disable=too-many-locals
assert popen.timer is None
- failed = bool(result)
+ failed = bool(result) and result not in allowed_return_codes
if out:
out = out.strip()
out = out if isinstance(out, str) else out.decode('utf-8', 'ignore')