From f5097a67ea816f6ecde3cd4ed621ee4c2647b6e3 Mon Sep 17 00:00:00 2001 From: FliegendeWurst Date: Sun, 5 Jan 2025 12:36:32 +0100 Subject: [PATCH] python313Packages.websockets: disable failing test, cleanup --- .../python-modules/websockets/default.nix | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/pkgs/development/python-modules/websockets/default.nix b/pkgs/development/python-modules/websockets/default.nix index d2ba63827282..0cd8813f694e 100644 --- a/pkgs/development/python-modules/websockets/default.nix +++ b/pkgs/development/python-modules/websockets/default.nix @@ -4,6 +4,7 @@ buildPythonPackage, fetchFromGitHub, unittestCheckHook, + pythonAtLeast, pythonOlder, setuptools, }: @@ -24,38 +25,36 @@ buildPythonPackage rec { build-system = [ setuptools ]; - patchPhase = - '' - # Disable all tests that need to terminate within a predetermined amount of - # time. This is nondeterministic. - sed -i 's/with self.assertCompletesWithin.*:/if True:/' \ - tests/legacy/test_protocol.py - + disabledTests = + [ # Disables tests relying on tight timeouts to avoid failures like: # File "/build/source/tests/legacy/test_protocol.py", line 1270, in test_keepalive_ping_with_no_ping_timeout # ping_1_again, ping_2 = tuple(self.protocol.pings) # ValueError: too many values to unpack (expected 2) - for t in \ - test_keepalive_ping_stops_when_connection_closing \ - test_keepalive_ping_does_not_crash_when_connection_lost \ - test_keepalive_ping \ - test_keepalive_ping_not_acknowledged_closes_connection \ - test_keepalive_ping_with_no_ping_timeout \ - ; do - sed -i "s/def $t(/def skip_$t(/" tests/legacy/test_protocol.py - done - '' - + lib.optionalString (pythonOlder "3.11") '' + "test_keepalive_ping_stops_when_connection_closing" + "test_keepalive_ping_does_not_crash_when_connection_lost" + "test_keepalive_ping" + "test_keepalive_ping_not_acknowledged_closes_connection" + "test_keepalive_ping_with_no_ping_timeout" + ] + ++ lib.optionals (pythonAtLeast "3.13") [ + # https://github.com/python-websockets/websockets/issues/1569 + "test_writing_in_send_context_fails" + ] + ++ lib.optionals (pythonOlder "3.11") [ # Our Python 3.10 and older raise SSLError instead of SSLCertVerificationError - sed -i "s/def test_reject_invalid_server_certificate(/def skip_test_reject_invalid_server_certificate(/" tests/sync/test_client.py - sed -i "s/def test_reject_invalid_server_certificate(/def skip_test_reject_invalid_server_certificate(/" tests/asyncio/test_client.py - ''; + "test_reject_invalid_server_certificate" + ]; nativeCheckInputs = [ unittestCheckHook ]; preCheck = '' # https://github.com/python-websockets/websockets/issues/1509 export WEBSOCKETS_TESTS_TIMEOUT_FACTOR=100 + # Disable all tests that need to terminate within a predetermined amount of + # time. This is nondeterministic. + sed -i 's/with self.assertCompletesWithin.*:/if True:/' \ + tests/legacy/test_protocol.py ''; # Tests fail on Darwin with `OSError: AF_UNIX path too long`