From df4d69bdeb466a61c6f2aa5551b9cc09fafffe9e Mon Sep 17 00:00:00 2001 From: euri10 Date: Sun, 12 Apr 2020 05:53:09 +0200 Subject: [PATCH] Test rebind socket oserror --- tests/test_config.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/test_config.py b/tests/test_config.py index 56d471492c..0c12fd9dae 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -165,11 +165,12 @@ def test_config_file_descriptor(socket_file): assert config.fd == fd -@pytest.mark.skipif( - not sys.platform.startswith("win"), reason="Triggers OSError only on Windows" -) -def test_config_file_descriptor_os_error(socket_file): - with pytest.raises(OSError): - uds, _, _ = socket_file - config = Config(app=asgi_app, uds=uds) - config.load() +def test_config_rebind_socket(): + sock = socket.socket() + config = Config(asgi_app) + sock.bind((config.host, config.port)) + with pytest.raises(SystemExit) as pytest_wrapped_e: + config.bind_socket() + assert pytest_wrapped_e.type == SystemExit + assert pytest_wrapped_e.value.code == 1 + sock.close()