From b22fe1ea8dd7bbed597890c19751872db00b11aa Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Wed, 15 Feb 2023 22:45:28 -0500 Subject: [PATCH] allow signature changes for 3.11 --- tests/core/server/test_event_loop.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/tests/core/server/test_event_loop.py b/tests/core/server/test_event_loop.py index 8de3e9ebf434..00ccda11dd46 100644 --- a/tests/core/server/test_event_loop.py +++ b/tests/core/server/test_event_loop.py @@ -2,6 +2,7 @@ from __future__ import annotations import asyncio import inspect +import sys import threading import pytest @@ -31,15 +32,21 @@ async def test_base_event_loop_has_methods() -> None: assert hasattr(base_selector_event_loop, "create_server") method = getattr(base_selector_event_loop, "create_server") assert inspect.ismethod(method) - expected_signature = "(protocol_factory, host=None, port=None, *, family=, flags=, sock=None, backlog=100, ssl=None, reuse_address=None, reuse_port=None, ssl_handshake_timeout=None, start_serving=True)" # noqa: E501 + if sys.version_info >= (3, 11): + expected_signature = "(protocol_factory, host=None, port=None, *, family=, flags=, sock=None, backlog=100, ssl=None, reuse_address=None, reuse_port=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None, start_serving=True)" # noqa: E501 + else: + expected_signature = "(protocol_factory, host=None, port=None, *, family=, flags=, sock=None, backlog=100, ssl=None, reuse_address=None, reuse_port=None, ssl_handshake_timeout=None, start_serving=True)" # noqa: E501 assert str(inspect.signature(method)) == expected_signature assert hasattr(base_selector_event_loop, "_start_serving") method = getattr(base_selector_event_loop, "_start_serving") assert inspect.ismethod(method) - expected_signature = ( - "(protocol_factory, sock, sslcontext=None, server=None, backlog=100, ssl_handshake_timeout=60.0)" - ) + if sys.version_info >= (3, 11): + expected_signature = "(protocol_factory, sock, sslcontext=None, server=None, backlog=100, ssl_handshake_timeout=60.0, ssl_shutdown_timeout=30.0)" # noqa: E501 + else: + expected_signature = ( + "(protocol_factory, sock, sslcontext=None, server=None, backlog=100, ssl_handshake_timeout=60.0)" + ) assert str(inspect.signature(method)) == expected_signature assert hasattr(base_selector_event_loop, "remove_reader") @@ -87,10 +94,13 @@ async def test_base_event_loop_has_methods() -> None: base_server = super(PausableServer, pausable_server) method = getattr(base_server, "__init__") - assert ( - str(inspect.signature(method)) - == "(loop, sockets, protocol_factory, ssl_context, backlog, ssl_handshake_timeout)" - ) + if sys.version_info >= (3, 11): + expected_signature = ( + "(loop, sockets, protocol_factory, ssl_context, backlog, ssl_handshake_timeout, ssl_shutdown_timeout=None)" + ) + else: + expected_signature = "(loop, sockets, protocol_factory, ssl_context, backlog, ssl_handshake_timeout)" + assert str(inspect.signature(method)) == expected_signature for func in ("_attach", "_detach"): assert hasattr(base_server, func)