diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 02080670d1..a30d56c197 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -191,7 +191,8 @@ repos: - flake8-pytest-style ~= 1.6.0 - flake8-spellcheck ~= 0.28.0 - wemake-python-styleguide ~= 1.1.0 - language_version: python3.11 # flake8-commas doesn't work w/ Python 3.12 + # Use Python 3.11 for CI compatibility (flake8-annotations not 3.14 ready) + language_version: python3.11 - repo: https://github.com/Lucas-C/pre-commit-hooks-lxml.git rev: v1.1.0 diff --git a/cheroot/test/conftest.py b/cheroot/test/conftest.py index db61bb0020..24dfc075f4 100644 --- a/cheroot/test/conftest.py +++ b/cheroot/test/conftest.py @@ -4,12 +4,14 @@ itself, useless for end-users' app testing. """ +import contextlib +import sys import threading import time import pytest -from .._compat import IS_MACOS, IS_WINDOWS # noqa: WPS436 +from .._compat import IS_MACOS, IS_WINDOWS from ..server import Gateway, HTTPServer from ..testing import ( # noqa: F401 # pylint: disable=unused-import get_server_client, @@ -20,6 +22,21 @@ ) +# Python 3.14 compatibility: Force 'fork' multiprocessing on Unix +# Python 3.14 changed default from 'fork' to 'forkserver' on Unix, +# which can cause issues with pytest-xdist's parallel test execution. +# This ensures compatibility with existing test fixtures and shared state. +# Note: Windows doesn't support 'fork', so we skip this on Windows. +# Ref: https://github.com/cherrypy/cheroot/issues/767 +if sys.version_info >= (3, 14) and not IS_WINDOWS: + with contextlib.suppress(ImportError): + import multiprocessing + + with contextlib.suppress(RuntimeError): + # Force fork method even if already set to forkserver + multiprocessing.set_start_method('fork', force=True) + + @pytest.fixture def http_request_timeout(): """Return a common HTTP request timeout for tests with queries.""" diff --git a/pytest.ini b/pytest.ini index 6586702144..261cdc3560 100644 --- a/pytest.ini +++ b/pytest.ini @@ -60,7 +60,19 @@ filterwarnings = # FIXME: Python 3.13 no longer ignores IOBase errors raised by the close(), # FIXME: which exposed a possible race condition in test_conn test cleanup. # Ref: https://github.com/cherrypy/cheroot/issues/734 - ignore:Exception ignored in.