Skip to content

Commit 24fe890

Browse files
committed
Move get_test_dirs to a separate file
1 parent 27dfcdb commit 24fe890

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

tests/hierarchy/get_test_dirs.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright (c) Jupyter Development Team.
2+
# Distributed under the terms of the Modified BSD License.
3+
from pathlib import Path
4+
5+
from tests.hierarchy.images_hierarchy import IMAGE_PARENT
6+
7+
THIS_DIR = Path(__file__).parent.resolve()
8+
IMAGE_SPECIFIC_TESTS_DIR = THIS_DIR.parent / "image_specific_tests"
9+
10+
assert IMAGE_SPECIFIC_TESTS_DIR.exists(), f"{IMAGE_SPECIFIC_TESTS_DIR} does not exist."
11+
12+
13+
def get_test_dirs(image: str | None) -> list[Path]:
14+
if image is None:
15+
return []
16+
17+
test_dirs = get_test_dirs(IMAGE_PARENT[image])
18+
current_test_dir = IMAGE_SPECIFIC_TESTS_DIR / image
19+
assert current_test_dir.exists(), f"{current_test_dir} does not exist."
20+
test_dirs.append(current_test_dir)
21+
return test_dirs

tests/hierarchy/images_hierarchy.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
# Copyright (c) Jupyter Development Team.
22
# Distributed under the terms of the Modified BSD License.
3-
from pathlib import Path
4-
5-
THIS_DIR = Path(__file__).parent.resolve()
6-
IMAGE_SPECIFIC_TESTS_DIR = THIS_DIR.parent / "image_specific_tests"
7-
8-
assert IMAGE_SPECIFIC_TESTS_DIR.exists(), f"{IMAGE_SPECIFIC_TESTS_DIR} does not exist."
93

104
# Please, take a look at the hierarchy of the images here:
115
# https://jupyter-docker-stacks.readthedocs.io/en/latest/using/selecting.html#image-relationships
12-
_IMAGE_PARENT = {
6+
IMAGE_PARENT = {
137
"docker-stacks-foundation": None,
148
"base-notebook": "docker-stacks-foundation",
159
"minimal-notebook": "base-notebook",
@@ -22,14 +16,3 @@
2216
"pyspark-notebook": "scipy-notebook",
2317
"all-spark-notebook": "pyspark-notebook",
2418
}
25-
26-
27-
def get_test_dirs(image: str | None) -> list[Path]:
28-
if image is None:
29-
return []
30-
31-
test_dirs = get_test_dirs(_IMAGE_PARENT[image])
32-
current_test_dir = IMAGE_SPECIFIC_TESTS_DIR / image
33-
assert current_test_dir.exists(), f"{current_test_dir} does not exist."
34-
test_dirs.append(current_test_dir)
35-
return test_dirs

tests/image_specific_tests/docker-stacks-foundation/test_units.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Distributed under the terms of the Modified BSD License.
33
import logging
44

5-
from tests.hierarchy.images_hierarchy import get_test_dirs
5+
from tests.hierarchy.get_test_dirs import get_test_dirs
66
from tests.utils.tracked_container import TrackedContainer
77

88
LOGGER = logging.getLogger(__name__)

tests/run_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import plumbum
88

9-
from tests.hierarchy.images_hierarchy import get_test_dirs
9+
from tests.hierarchy.get_test_dirs import get_test_dirs
1010

1111
python3 = plumbum.local["python3"]
1212

0 commit comments

Comments
 (0)