diff --git a/base-notebook/test/test_container_options.py b/base-notebook/test/test_container_options.py index b21bf7b4..65e85d24 100644 --- a/base-notebook/test/test_container_options.py +++ b/base-notebook/test/test_container_options.py @@ -20,7 +20,7 @@ def test_cli_args(container: TrackedContainer, http_client: requests.Session) -> ports={"8888/tcp": None}, ) host_port = container.get_host_port("8888/tcp") - resp = http_client.get("http://localhost:" + host_port) + resp = http_client.get(f"http://localhost:{host_port}") resp.raise_for_status() logs = running_container.logs().decode("utf-8") LOGGER.debug(logs) @@ -47,7 +47,7 @@ def test_unsigned_ssl( # abort the retry logic. Forcing a long sleep for the moment until I have # time to dig more. time.sleep(5) - resp = http_client.get("https://localhost:" + host_port, verify=False) + resp = http_client.get(f"https://localhost:{host_port}", verify=False) resp.raise_for_status() assert "login_submit" in resp.text logs = running_container.logs().decode("utf-8") diff --git a/base-notebook/test/test_start_container.py b/base-notebook/test/test_start_container.py index e72988be..7d9b30f9 100644 --- a/base-notebook/test/test_start_container.py +++ b/base-notebook/test/test_start_container.py @@ -70,7 +70,7 @@ def test_start_notebook( # checking if the server is listening if expected_start: host_port = container.get_host_port("8888/tcp") - resp = http_client.get("http://localhost:" + host_port) + resp = http_client.get(f"http://localhost:{host_port}") assert resp.status_code == 200, "Server is not listening" diff --git a/conftest.py b/conftest.py index 5f57ff3f..a0026265 100644 --- a/conftest.py +++ b/conftest.py @@ -109,6 +109,7 @@ class TrackedContainer: return logs def get_host_port(self, container_port: str) -> str: + """Returns the host port associated with the tracked container's port.""" assert isinstance(self.container, Container) self.container.reload() return self.container.attrs["NetworkSettings"]["Ports"][container_port][0][ diff --git a/test/test_notebook.py b/test/test_notebook.py index 390649ec..163e1ecd 100644 --- a/test/test_notebook.py +++ b/test/test_notebook.py @@ -12,6 +12,6 @@ def test_secured_server( """Notebook server should eventually request user login.""" container.run_detached(ports={"8888/tcp": None}) host_port = container.get_host_port("8888/tcp") - resp = http_client.get("http://localhost:" + host_port) + resp = http_client.get(f"http://localhost:{host_port}") resp.raise_for_status() assert "login_submit" in resp.text, "User login not requested"