Choose random host port in tests

This commit is contained in:
Ayaz Salikhov
2022-02-14 14:15:08 +03:00
parent 1ef883888b
commit 5ebb4bd0f2
4 changed files with 23 additions and 8 deletions

View File

@@ -51,6 +51,7 @@ def test_start_notebook(
tty=True,
environment=env,
command=["start-notebook.sh"],
ports={"8888/tcp": None},
)
# sleeping some time to let the server start
time.sleep(3)
@@ -68,7 +69,8 @@ def test_start_notebook(
assert len(expected_warnings) == len(warnings)
# checking if the server is listening
if expected_start:
resp = http_client.get("http://localhost:8888")
host_port = container.get_host_port("8888/tcp")
resp = http_client.get("http://localhost:" + host_port)
assert resp.status_code == 200, "Server is not listening"