From 2f219dbbd7d1c4db1d7b1f24704fa48537ca4e4c Mon Sep 17 00:00:00 2001 From: Adam Hopkins Date: Sun, 26 Mar 2023 14:59:09 +0300 Subject: [PATCH] Version 23.3 compat (#65) * No failure on dupe exception handler * Make pretty * Bump version * make pretty --- sanic_testing/__init__.py | 2 +- sanic_testing/testing.py | 8 +++++--- tests/test_asgi_client.py | 1 - 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/sanic_testing/__init__.py b/sanic_testing/__init__.py index 23ed28d..74d49c9 100644 --- a/sanic_testing/__init__.py +++ b/sanic_testing/__init__.py @@ -1,4 +1,4 @@ from sanic_testing.manager import TestManager -__version__ = "22.12.0" +__version__ = "23.3.0" __all__ = ("TestManager",) diff --git a/sanic_testing/testing.py b/sanic_testing/testing.py index de77f7e..7bedf22 100644 --- a/sanic_testing/testing.py +++ b/sanic_testing/testing.py @@ -8,7 +8,7 @@ import httpx from sanic import Sanic # type: ignore from sanic.asgi import ASGIApp # type: ignore -from sanic.exceptions import MethodNotSupported # type: ignore +from sanic.exceptions import MethodNotSupported, ServerError # type: ignore from sanic.log import logger # type: ignore from sanic.request import Request # type: ignore from sanic.response import text # type: ignore @@ -96,7 +96,6 @@ async def _local_request(self, method: str, url: str, *args, **kwargs): return await websocket_proxy(url, *args, **kwargs) else: async with self.get_new_session(**session_kwargs) as session: - try: if method == "request": args = tuple([url] + list(args)) @@ -184,7 +183,10 @@ def _sanic_endpoint_test( _collect_request ) - self.app.exception(MethodNotSupported)(self._error_handler) + try: + self.app.exception(MethodNotSupported)(self._error_handler) + except ServerError: + ... if self.port: server_kwargs = dict( diff --git a/tests/test_asgi_client.py b/tests/test_asgi_client.py index ebec8be..4f2f8ce 100644 --- a/tests/test_asgi_client.py +++ b/tests/test_asgi_client.py @@ -19,7 +19,6 @@ async def test_basic_asgi_client(app, method): @pytest.mark.asyncio async def test_websocket_route(app): - ev = asyncio.Event() @app.websocket("/ws")