Skip to content

Commit 81a93d2

Browse files
authored
Merge pull request #1673 from mathbunnyru/asalikhov/modules
Make tests a module and make imports absolute
2 parents 05c4ef4 + c6ae418 commit 81a93d2

28 files changed

+61
-41
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,6 @@ run-sudo-shell/%: ## run a bash in interactive mode as root in a stack
207207

208208
test/%: ## run tests against a stack
209209
@echo "::group::test/$(OWNER)/$(notdir $@)"
210-
tests/run_tests.py --short-image-name "$(notdir $@)" --owner "$(OWNER)"
210+
python3 -m tests.run_tests --short-image-name "$(notdir $@)" --owner "$(OWNER)"
211211
@echo "::endgroup::"
212212
test-all: $(foreach I, $(ALL_IMAGES), test/$(I)) ## test all stacks

tagging/README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ In this section we will briefly describe source code in this folder and give exa
2727
`DockerRunner` is a helper class to easily run a docker container and execute commands inside this container:
2828

2929
```python
30-
from .docker_runner import DockerRunner
30+
from tagging.docker_runner import DockerRunner
3131

3232
with DockerRunner("ubuntu:bionic") as container:
3333
DockerRunner.run_simple_command(container, cmd="env", print_result=True)
@@ -38,7 +38,7 @@ with DockerRunner("ubuntu:bionic") as container:
3838
`GitHelper` methods are run in the current `git` repo and give the information about last commit hash and commit message:
3939

4040
```python
41-
from .git_helper import GitHelper
41+
from tagging.git_helper import GitHelper
4242

4343
print("Git hash:", GitHelper.commit_hash())
4444
print("Git message:", GitHelper.commit_message())
@@ -66,6 +66,10 @@ So, `tag_value(container)` method gets a docker container as an input and return
6666
`SHATagger` example:
6767

6868
```python
69+
from tagging.git_helper import GitHelper
70+
from tagging.taggers import TaggerInterface
71+
72+
6973
class SHATagger(TaggerInterface):
7074
@staticmethod
7175
def tag_value(container):
@@ -96,6 +100,9 @@ class ManifestInterface:
96100
`AptPackagesManifest` example:
97101

98102
```python
103+
from tagging.manifests import ManifestInterface, quoted_output
104+
105+
99106
class AptPackagesManifest(ManifestInterface):
100107
@staticmethod
101108
def markdown_piece(container) -> str:

tagging/create_manifests.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
from docker.models.containers import Container
1010

11-
from .docker_runner import DockerRunner
12-
from .get_taggers_and_manifests import get_taggers_and_manifests
13-
from .git_helper import GitHelper
14-
from .manifests import ManifestHeader, ManifestInterface
11+
from tagging.docker_runner import DockerRunner
12+
from tagging.get_taggers_and_manifests import get_taggers_and_manifests
13+
from tagging.git_helper import GitHelper
14+
from tagging.manifests import ManifestHeader, ManifestInterface
1515

1616
LOGGER = logging.getLogger(__name__)
1717

tagging/get_taggers_and_manifests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# Distributed under the terms of the Modified BSD License.
33
from typing import Optional
44

5-
from .images_hierarchy import ALL_IMAGES
6-
from .manifests import ManifestInterface
7-
from .taggers import TaggerInterface
5+
from tagging.images_hierarchy import ALL_IMAGES
6+
from tagging.manifests import ManifestInterface
7+
from tagging.taggers import TaggerInterface
88

99

1010
def get_taggers_and_manifests(

tagging/images_hierarchy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
from dataclasses import dataclass, field
44
from typing import Optional
55

6-
from .manifests import (
6+
from tagging.manifests import (
77
AptPackagesManifest,
88
CondaEnvironmentManifest,
99
JuliaPackagesManifest,
1010
ManifestInterface,
1111
RPackagesManifest,
1212
SparkInfoManifest,
1313
)
14-
from .taggers import (
14+
from tagging.taggers import (
1515
DateTagger,
1616
HadoopVersionTagger,
1717
JavaVersionTagger,

tagging/manifests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import plumbum
44
from docker.models.containers import Container
55

6-
from .docker_runner import DockerRunner
7-
from .git_helper import GitHelper
6+
from tagging.docker_runner import DockerRunner
7+
from tagging.git_helper import GitHelper
88

99
docker = plumbum.local["docker"]
1010

tagging/tag_image.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
import plumbum
88

9-
from .docker_runner import DockerRunner
10-
from .get_taggers_and_manifests import get_taggers_and_manifests
11-
from .github_set_env import github_set_env
9+
from tagging.docker_runner import DockerRunner
10+
from tagging.get_taggers_and_manifests import get_taggers_and_manifests
11+
from tagging.github_set_env import github_set_env
1212

1313
docker = plumbum.local["docker"]
1414

tagging/taggers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
from docker.models.containers import Container
66

7-
from .docker_runner import DockerRunner
8-
from .git_helper import GitHelper
7+
from tagging.docker_runner import DockerRunner
8+
from tagging.git_helper import GitHelper
99

1010

1111
def _get_program_version(container: Container, program: str) -> str:

tests/__init__.py

Whitespace-only changes.

tests/all-spark-notebook/test_spark_notebooks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
from pathlib import Path
66

77
import pytest # type: ignore
8-
from conftest import TrackedContainer
8+
9+
from tests.conftest import TrackedContainer
910

1011
LOGGER = logging.getLogger(__name__)
1112
THIS_DIR = Path(__file__).parent.resolve()

tests/base-notebook/test_container_options.py

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

77
import pytest # type: ignore
88
import requests
9-
from conftest import TrackedContainer, find_free_port
9+
10+
from tests.conftest import TrackedContainer, find_free_port
1011

1112
LOGGER = logging.getLogger(__name__)
1213

tests/base-notebook/test_notebook.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44

55
import requests
6-
from conftest import TrackedContainer, find_free_port
6+
7+
from tests.conftest import TrackedContainer, find_free_port
78

89

910
def test_secured_server(

tests/base-notebook/test_outdated.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
import logging
55

66
import pytest # type: ignore
7-
from conftest import TrackedContainer
8-
from package_helper import CondaPackageHelper
7+
8+
from tests.conftest import TrackedContainer
9+
from tests.package_helper import CondaPackageHelper
910

1011
LOGGER = logging.getLogger(__name__)
1112

tests/base-notebook/test_package_managers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import logging
55

66
import pytest # type: ignore
7-
from conftest import TrackedContainer
7+
8+
from tests.conftest import TrackedContainer
89

910
LOGGER = logging.getLogger(__name__)
1011

tests/base-notebook/test_packages.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@
4141
from typing import Callable, Iterable
4242

4343
import pytest # type: ignore
44-
from conftest import TrackedContainer
45-
from package_helper import CondaPackageHelper
44+
45+
from tests.conftest import TrackedContainer
46+
from tests.package_helper import CondaPackageHelper
4647

4748
LOGGER = logging.getLogger(__name__)
4849

tests/base-notebook/test_pandoc.py

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

44
import logging
55

6-
from conftest import TrackedContainer
6+
from tests.conftest import TrackedContainer
77

88
LOGGER = logging.getLogger(__name__)
99

tests/base-notebook/test_python.py

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

5-
from conftest import TrackedContainer
65
from packaging import version # type: ignore
76

7+
from tests.conftest import TrackedContainer
8+
89
LOGGER = logging.getLogger(__name__)
910

1011

tests/base-notebook/test_start_container.py

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

88
import pytest # type: ignore
99
import requests
10-
from conftest import TrackedContainer, find_free_port
10+
11+
from tests.conftest import TrackedContainer, find_free_port
1112

1213
LOGGER = logging.getLogger(__name__)
1314

tests/base-notebook/test_units.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
import logging
55

6-
from conftest import TrackedContainer
7-
from images_hierarchy import get_test_dirs
6+
from tests.conftest import TrackedContainer
7+
from tests.images_hierarchy import get_test_dirs
88

99
LOGGER = logging.getLogger(__name__)
1010

tests/datascience-notebook/test_julia.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 conftest import TrackedContainer
5+
from tests.conftest import TrackedContainer
66

77
LOGGER = logging.getLogger(__name__)
88

tests/minimal-notebook/test_inkscape.py

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

44
import logging
55

6-
from conftest import TrackedContainer
6+
from tests.conftest import TrackedContainer
77

88
LOGGER = logging.getLogger(__name__)
99

tests/minimal-notebook/test_nbconvert.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
from pathlib import Path
66

77
import pytest # type: ignore
8-
from conftest import TrackedContainer
8+
9+
from tests.conftest import TrackedContainer
910

1011
LOGGER = logging.getLogger(__name__)
1112
THIS_DIR = Path(__file__).parent.resolve()

tests/package_helper.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@
2929
from itertools import chain
3030
from typing import Any, Optional
3131

32-
from conftest import TrackedContainer
3332
from docker.models.containers import Container
3433
from tabulate import tabulate
3534

35+
from tests.conftest import TrackedContainer
36+
3637
LOGGER = logging.getLogger(__name__)
3738

3839

tests/pyspark-notebook/test_spark.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 conftest import TrackedContainer
5+
from tests.conftest import TrackedContainer
66

77
LOGGER = logging.getLogger(__name__)
88

tests/run_tests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
import logging
66

77
import plumbum
8-
from images_hierarchy import get_test_dirs
8+
9+
from tests.images_hierarchy import get_test_dirs
910

1011
pytest = plumbum.local["pytest"]
1112

tests/scipy-notebook/test_cython.py

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

44
from pathlib import Path
55

6-
from conftest import TrackedContainer
6+
from tests.conftest import TrackedContainer
77

88
THIS_DIR = Path(__file__).parent.resolve()
99

tests/scipy-notebook/test_extensions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import logging
44

55
import pytest # type: ignore
6-
from conftest import TrackedContainer
6+
7+
from tests.conftest import TrackedContainer
78

89
LOGGER = logging.getLogger(__name__)
910

tests/scipy-notebook/test_matplotlib.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
from pathlib import Path
66

77
import pytest # type: ignore
8-
from conftest import TrackedContainer
8+
9+
from tests.conftest import TrackedContainer
910

1011
LOGGER = logging.getLogger(__name__)
1112
THIS_DIR = Path(__file__).parent.resolve()

0 commit comments

Comments
 (0)