Skip to content

Commit 6daff79

Browse files
authored
Merge branch 'main' into python3.13
2 parents c1ff7d8 + 8432e57 commit 6daff79

30 files changed

+292
-292
lines changed

requirements-dev.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ docker
22
plumbum
33
pre-commit
44
pytest
5-
pytest-retry
65
# `pytest-xdist` is a plugin that provides the `--numprocesses` flag,
76
# allowing us to run `pytest` tests in parallel
87
pytest-xdist

tests/by_image/all-spark-notebook/test_spark_notebooks.py

Lines changed: 0 additions & 43 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright (c) Jupyter Development Team.
2+
# Distributed under the terms of the Modified BSD License.
3+
import logging
4+
from pathlib import Path
5+
6+
import pytest # type: ignore
7+
8+
from tests.shared_checks.nbconvert_check import check_nbconvert
9+
from tests.utils.tracked_container import TrackedContainer
10+
11+
LOGGER = logging.getLogger(__name__)
12+
THIS_DIR = Path(__file__).parent.resolve()
13+
14+
15+
@pytest.mark.parametrize(
16+
"test_file,expected_warnings",
17+
[
18+
("local_sparkR", ["WARNING: Using incubator modules: jdk.incubator.vector"]),
19+
("local_sparklyr", []),
20+
],
21+
)
22+
@pytest.mark.parametrize("output_format", ["pdf", "html", "markdown"])
23+
def test_spark_r_nbconvert(
24+
container: TrackedContainer,
25+
test_file: str,
26+
output_format: str,
27+
expected_warnings: list[str],
28+
) -> None:
29+
host_data_file = THIS_DIR / "data" / f"{test_file}.ipynb"
30+
logs = check_nbconvert(
31+
container,
32+
host_data_file,
33+
output_format,
34+
execute=True,
35+
no_warnings=(not expected_warnings),
36+
)
37+
38+
if expected_warnings:
39+
warnings = TrackedContainer.get_warnings(logs)
40+
assert len(warnings) == len(expected_warnings)
41+
assert expected_warnings[0] == warnings[0]

tests/by_image/base-notebook/test_container_options.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@
66
import pytest # type: ignore
77
import requests
88

9-
from tests.utils.find_free_port import find_free_port
109
from tests.utils.tracked_container import TrackedContainer
1110

1211
LOGGER = logging.getLogger(__name__)
1312

1413

15-
def test_cli_args(container: TrackedContainer, http_client: requests.Session) -> None:
14+
def test_cli_args(
15+
container: TrackedContainer, http_client: requests.Session, free_host_port: int
16+
) -> None:
1617
"""Image should respect command line args (e.g., disabling token security)"""
17-
host_port = find_free_port()
1818
container.run_detached(
1919
command=["start-notebook.py", "--IdentityProvider.token=''"],
20-
ports={"8888/tcp": host_port},
20+
ports={"8888/tcp": free_host_port},
2121
)
22-
resp = http_client.get(f"http://localhost:{host_port}")
22+
resp = http_client.get(f"http://localhost:{free_host_port}")
2323
resp.raise_for_status()
2424
logs = container.get_logs()
2525
LOGGER.debug(logs)
@@ -35,7 +35,7 @@ def test_nb_user_change(container: TrackedContainer) -> None:
3535
container.run_detached(
3636
user="root",
3737
environment=[f"NB_USER={nb_user}", "CHOWN_HOME=yes"],
38-
command=["bash", "-c", "sleep infinity"],
38+
command=["sleep", "infinity"],
3939
)
4040

4141
# Give the chown time to complete.
@@ -54,22 +54,21 @@ def test_nb_user_change(container: TrackedContainer) -> None:
5454

5555
@pytest.mark.filterwarnings("ignore:Unverified HTTPS request")
5656
def test_unsigned_ssl(
57-
container: TrackedContainer, http_client: requests.Session
57+
container: TrackedContainer, http_client: requests.Session, free_host_port: int
5858
) -> None:
5959
"""Container should generate a self-signed SSL certificate
6060
and Jupyter Server should use it to enable HTTPS.
6161
"""
62-
host_port = find_free_port()
6362
container.run_detached(
6463
environment=["GEN_CERT=yes"],
65-
ports={"8888/tcp": host_port},
64+
ports={"8888/tcp": free_host_port},
6665
)
6766
# NOTE: The requests.Session backing the http_client fixture
6867
# does not retry properly while the server is booting up.
6968
# An SSL handshake error seems to abort the retry logic.
7069
# Forcing a long sleep for the moment until I have time to dig more.
7170
time.sleep(1)
72-
resp = http_client.get(f"https://localhost:{host_port}", verify=False)
71+
resp = http_client.get(f"https://localhost:{free_host_port}", verify=False)
7372
resp.raise_for_status()
7473
assert "login_submit" in resp.text
7574
logs = container.get_logs()
@@ -94,18 +93,18 @@ def test_unsigned_ssl(
9493
def test_custom_internal_port(
9594
container: TrackedContainer,
9695
http_client: requests.Session,
96+
free_host_port: int,
9797
env: dict[str, str],
9898
) -> None:
9999
"""Container should be accessible from the host
100100
when using custom internal port"""
101-
host_port = find_free_port()
102101
internal_port = env.get("JUPYTER_PORT", 8888)
103102
container.run_detached(
104103
command=["start-notebook.py", "--IdentityProvider.token=''"],
105104
environment=env,
106-
ports={internal_port: host_port},
105+
ports={internal_port: free_host_port},
107106
)
108-
resp = http_client.get(f"http://localhost:{host_port}")
107+
resp = http_client.get(f"http://localhost:{free_host_port}")
109108
resp.raise_for_status()
110109
logs = container.get_logs()
111110
LOGGER.debug(logs)

tests/by_image/base-notebook/test_ips.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ def ipv6_network(docker_client: docker.DockerClient) -> Generator[str, None, Non
3535

3636
def test_ipv46(container: TrackedContainer, ipv6_network: str) -> None:
3737
"""Check server is listening on the expected IP families"""
38-
host_data_dir = THIS_DIR / "data"
39-
cont_data_dir = "/home/jovyan/data"
38+
file_name = "check_listening.py"
39+
host_file = THIS_DIR / "data" / file_name
40+
cont_file = f"/home/jovyan/data/{file_name}"
4041
LOGGER.info("Testing that server is listening on IPv4 and IPv6 ...")
4142
container.run_detached(
4243
network=ipv6_network,
43-
volumes={str(host_data_dir): {"bind": cont_data_dir, "mode": "ro,z"}},
44+
volumes={host_file: {"bind": cont_file, "mode": "ro"}},
4445
)
45-
container.exec_cmd(f"python {cont_data_dir}/check_listening.py")
46+
container.exec_cmd(f"python {cont_file}")

tests/by_image/base-notebook/test_notebook.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22
# Distributed under the terms of the Modified BSD License.
33
import requests
44

5-
from tests.utils.find_free_port import find_free_port
65
from tests.utils.tracked_container import TrackedContainer
76

87

98
def test_secured_server(
10-
container: TrackedContainer, http_client: requests.Session
9+
container: TrackedContainer, http_client: requests.Session, free_host_port: int
1110
) -> None:
1211
"""Jupyter Server should eventually request user login."""
13-
host_port = find_free_port()
14-
container.run_detached(ports={"8888/tcp": host_port})
15-
resp = http_client.get(f"http://localhost:{host_port}")
12+
container.run_detached(ports={"8888/tcp": free_host_port})
13+
resp = http_client.get(f"http://localhost:{free_host_port}")
1614
resp.raise_for_status()
1715
assert "login_submit" in resp.text, "User login not requested"

tests/by_image/base-notebook/test_start_container.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import pytest # type: ignore
77
import requests
88

9-
from tests.utils.find_free_port import find_free_port
109
from tests.utils.tracked_container import TrackedContainer
1110

1211
LOGGER = logging.getLogger(__name__)
@@ -32,6 +31,7 @@
3231
def test_start_notebook(
3332
container: TrackedContainer,
3433
http_client: requests.Session,
34+
free_host_port: int,
3535
env: list[str] | None,
3636
expected_command: str,
3737
expected_start: bool,
@@ -41,8 +41,7 @@ def test_start_notebook(
4141
LOGGER.info(
4242
f"Test that the start-notebook.py launches the {expected_command} server from the env {env} ..."
4343
)
44-
host_port = find_free_port()
45-
container.run_detached(environment=env, ports={"8888/tcp": host_port})
44+
container.run_detached(environment=env, ports={"8888/tcp": free_host_port})
4645
# sleeping some time to let the server start
4746
time.sleep(2)
4847
logs = container.get_logs()
@@ -59,7 +58,7 @@ def test_start_notebook(
5958
assert len(expected_warnings) == len(warnings)
6059
# checking if the server is listening
6160
if expected_start:
62-
resp = http_client.get(f"http://localhost:{host_port}")
61+
resp = http_client.get(f"http://localhost:{free_host_port}")
6362
assert resp.status_code == 200, "Server is not listening"
6463

6564

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Copyright (c) Jupyter Development Team.
22
# Distributed under the terms of the Modified BSD License.
3-
from tests.utils.run_command import run_command
43
from tests.utils.tracked_container import TrackedContainer
54

65

76
def test_julia(container: TrackedContainer) -> None:
8-
run_command(container, "julia --version")
7+
container.run_and_wait(timeout=5, command=["julia", "--version"])

tests/by_image/datascience-notebook/test_pluto_datascience.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
def test_pluto_proxy(
10-
container: TrackedContainer, http_client: requests.Session
10+
container: TrackedContainer, http_client: requests.Session, free_host_port: int
1111
) -> None:
1212
"""Pluto proxy starts Pluto correctly"""
13-
check_pluto_proxy(container, http_client)
13+
check_pluto_proxy(container, http_client, free_host_port)

tests/by_image/docker-stacks-foundation/test_outdated.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010
LOGGER = logging.getLogger(__name__)
1111

1212

13+
@pytest.mark.parametrize("requested_only", [True, False])
1314
@pytest.mark.info
14-
def test_outdated_packages(
15-
container: TrackedContainer, requested_only: bool = True
16-
) -> None:
15+
def test_outdated_packages(container: TrackedContainer, requested_only: bool) -> None:
1716
"""Getting the list of updatable packages"""
1817
LOGGER.info(f"Checking outdated packages in {container.image_name} ...")
1918
pkg_helper = CondaPackageHelper(container)
20-
pkg_helper.check_updatable_packages(requested_only)
21-
LOGGER.info(pkg_helper.get_outdated_summary(requested_only))
22-
LOGGER.info(f"\n{pkg_helper.get_outdated_table()}\n")
19+
updatable = pkg_helper.find_updatable_packages(requested_only)
20+
LOGGER.info(pkg_helper.get_outdated_summary(updatable, requested_only))
21+
LOGGER.info(
22+
f"Outdated packages table:\n{pkg_helper.get_outdated_table(updatable)}\n"
23+
)

0 commit comments

Comments
 (0)