From 6429d06c2829b6f7197532c81f5e61f61d32420c Mon Sep 17 00:00:00 2001 From: Kostya Leschenko Date: Thu, 25 Apr 2024 16:58:32 +0300 Subject: [PATCH] Remove unused context managers --- tests/test_server.py | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/tests/test_server.py b/tests/test_server.py index 1ed392673..0835cf509 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -1,10 +1,8 @@ from __future__ import annotations import asyncio -import contextlib import signal import sys -from typing import Generator import pytest @@ -12,27 +10,6 @@ from uvicorn.server import Server -# asyncio does NOT allow raising in signal handlers, so to detect -# raised signals raised a mutable `witness` receives the signal -@contextlib.contextmanager -def capture_signal_sync(sig: signal.Signals) -> Generator[list[int], None, None]: - """Replace `sig` handling with a normal exception via `signal""" - witness: list[int] = [] - original_handler = signal.signal(sig, lambda signum, frame: witness.append(signum)) - yield witness - signal.signal(sig, original_handler) - - -@contextlib.contextmanager -def capture_signal_async(sig: signal.Signals) -> Generator[list[int], None, None]: # pragma: py-win32 - """Replace `sig` handling with a normal exception via `asyncio""" - witness: list[int] = [] - original_handler = signal.getsignal(sig) - asyncio.get_running_loop().add_signal_handler(sig, witness.append, sig) - yield witness - signal.signal(sig, original_handler) - - async def dummy_app(scope, receive, send): # pragma: py-win32 pass