Skip to content

Commit dec5d33

Browse files
authored
[3.12] Use unix_sockname fixture for test_run_app_preexisting_unix_socket (#11502)
Manual backport of #11498.
1 parent 8a7bd00 commit dec5d33

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

tests/test_run_app.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -621,22 +621,21 @@ def test_run_app_preexisting_inet6_socket(patched_loop) -> None:
621621

622622

623623
@pytest.mark.skipif(not hasattr(socket, "AF_UNIX"), reason="requires UNIX sockets")
624-
def test_run_app_preexisting_unix_socket(patched_loop, mocker) -> None:
624+
def test_run_app_preexisting_unix_socket(patched_loop, unix_sockname, mocker) -> None:
625625
app = web.Application()
626626

627-
sock_path = "/tmp/test_preexisting_sock1"
628627
sock = socket.socket(socket.AF_UNIX)
629628
with contextlib.closing(sock):
630-
sock.bind(sock_path)
631-
os.unlink(sock_path)
629+
sock.bind(unix_sockname)
630+
os.unlink(unix_sockname)
632631

633632
printer = mock.Mock(wraps=stopper(patched_loop))
634633
web.run_app(app, sock=sock, print=printer, loop=patched_loop)
635634

636635
patched_loop.create_server.assert_called_with(
637636
mock.ANY, sock=sock, backlog=128, ssl=None
638637
)
639-
assert f"http://unix:{sock_path}:" in printer.call_args[0][0]
638+
assert f"http://unix:{unix_sockname}:" in printer.call_args[0][0]
640639

641640

642641
def test_run_app_multiple_preexisting_sockets(patched_loop) -> None:

0 commit comments

Comments
 (0)