Skip to content

Commit

Permalink
Test rebind socket oserror
Browse files Browse the repository at this point in the history
  • Loading branch information
euri10 committed Apr 12, 2020
1 parent c5e53d1 commit df4d69b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit df4d69b

Please sign in to comment.