mirror of
https://github.com/jupyter/docker-stacks.git
synced 2025-10-07 01:54:04 +00:00
Make tests a module and make imports absolute
This commit is contained in:
2
Makefile
2
Makefile
@@ -207,6 +207,6 @@ run-sudo-shell/%: ## run a bash in interactive mode as root in a stack
|
||||
|
||||
test/%: ## run tests against a stack
|
||||
@echo "::group::test/$(OWNER)/$(notdir $@)"
|
||||
tests/run_tests.py --short-image-name "$(notdir $@)" --owner "$(OWNER)"
|
||||
python3 -m tests.run_tests --short-image-name "$(notdir $@)" --owner "$(OWNER)"
|
||||
@echo "::endgroup::"
|
||||
test-all: $(foreach I, $(ALL_IMAGES), test/$(I)) ## test all stacks
|
||||
|
@@ -27,7 +27,7 @@ In this section we will briefly describe source code in this folder and give exa
|
||||
`DockerRunner` is a helper class to easily run a docker container and execute commands inside this container:
|
||||
|
||||
```python
|
||||
from .docker_runner import DockerRunner
|
||||
from tagging.docker_runner import DockerRunner
|
||||
|
||||
with DockerRunner("ubuntu:bionic") as container:
|
||||
DockerRunner.run_simple_command(container, cmd="env", print_result=True)
|
||||
@@ -38,7 +38,7 @@ with DockerRunner("ubuntu:bionic") as container:
|
||||
`GitHelper` methods are run in the current `git` repo and give the information about last commit hash and commit message:
|
||||
|
||||
```python
|
||||
from .git_helper import GitHelper
|
||||
from tagging.git_helper import GitHelper
|
||||
|
||||
print("Git hash:", GitHelper.commit_hash())
|
||||
print("Git message:", GitHelper.commit_message())
|
||||
@@ -66,6 +66,9 @@ So, `tag_value(container)` method gets a docker container as an input and return
|
||||
`SHATagger` example:
|
||||
|
||||
```python
|
||||
from tagging.git_helper import GitHelper
|
||||
from tagging.taggers import import TaggerInterface
|
||||
|
||||
class SHATagger(TaggerInterface):
|
||||
@staticmethod
|
||||
def tag_value(container):
|
||||
@@ -96,6 +99,9 @@ class ManifestInterface:
|
||||
`AptPackagesManifest` example:
|
||||
|
||||
```python
|
||||
from tagging.manifests import ManifestInterface, quoted_output
|
||||
|
||||
|
||||
class AptPackagesManifest(ManifestInterface):
|
||||
@staticmethod
|
||||
def markdown_piece(container) -> str:
|
||||
|
@@ -8,10 +8,10 @@ import os
|
||||
|
||||
from docker.models.containers import Container
|
||||
|
||||
from .docker_runner import DockerRunner
|
||||
from .get_taggers_and_manifests import get_taggers_and_manifests
|
||||
from .git_helper import GitHelper
|
||||
from .manifests import ManifestHeader, ManifestInterface
|
||||
from tagging.docker_runner import DockerRunner
|
||||
from tagging.get_taggers_and_manifests import get_taggers_and_manifests
|
||||
from tagging.git_helper import GitHelper
|
||||
from tagging.manifests import ManifestHeader, ManifestInterface
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@@ -2,9 +2,9 @@
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
from typing import Optional
|
||||
|
||||
from .images_hierarchy import ALL_IMAGES
|
||||
from .manifests import ManifestInterface
|
||||
from .taggers import TaggerInterface
|
||||
from tagging.images_hierarchy import ALL_IMAGES
|
||||
from tagging.manifests import ManifestInterface
|
||||
from tagging.taggers import TaggerInterface
|
||||
|
||||
|
||||
def get_taggers_and_manifests(
|
||||
|
@@ -3,7 +3,7 @@
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Optional
|
||||
|
||||
from .manifests import (
|
||||
from tagging.manifests import (
|
||||
AptPackagesManifest,
|
||||
CondaEnvironmentManifest,
|
||||
JuliaPackagesManifest,
|
||||
@@ -11,7 +11,7 @@ from .manifests import (
|
||||
RPackagesManifest,
|
||||
SparkInfoManifest,
|
||||
)
|
||||
from .taggers import (
|
||||
from tagging.taggers import (
|
||||
DateTagger,
|
||||
HadoopVersionTagger,
|
||||
JavaVersionTagger,
|
||||
|
@@ -3,8 +3,8 @@
|
||||
import plumbum
|
||||
from docker.models.containers import Container
|
||||
|
||||
from .docker_runner import DockerRunner
|
||||
from .git_helper import GitHelper
|
||||
from tagging.docker_runner import DockerRunner
|
||||
from tagging.git_helper import GitHelper
|
||||
|
||||
docker = plumbum.local["docker"]
|
||||
|
||||
|
@@ -6,9 +6,9 @@ import logging
|
||||
|
||||
import plumbum
|
||||
|
||||
from .docker_runner import DockerRunner
|
||||
from .get_taggers_and_manifests import get_taggers_and_manifests
|
||||
from .github_set_env import github_set_env
|
||||
from tagging.docker_runner import DockerRunner
|
||||
from tagging.get_taggers_and_manifests import get_taggers_and_manifests
|
||||
from tagging.github_set_env import github_set_env
|
||||
|
||||
docker = plumbum.local["docker"]
|
||||
|
||||
|
@@ -4,8 +4,8 @@ from datetime import datetime
|
||||
|
||||
from docker.models.containers import Container
|
||||
|
||||
from .docker_runner import DockerRunner
|
||||
from .git_helper import GitHelper
|
||||
from tagging.docker_runner import DockerRunner
|
||||
from tagging.git_helper import GitHelper
|
||||
|
||||
|
||||
def _get_program_version(container: Container, program: str) -> str:
|
||||
|
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
@@ -5,7 +5,8 @@ import logging
|
||||
from pathlib import Path
|
||||
|
||||
import pytest # type: ignore
|
||||
from conftest import TrackedContainer
|
||||
|
||||
from tests.conftest import TrackedContainer
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
THIS_DIR = Path(__file__).parent.resolve()
|
||||
|
@@ -6,7 +6,8 @@ import time
|
||||
|
||||
import pytest # type: ignore
|
||||
import requests
|
||||
from conftest import TrackedContainer, find_free_port
|
||||
|
||||
from tests.conftest import TrackedContainer, find_free_port
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@@ -3,7 +3,8 @@
|
||||
|
||||
|
||||
import requests
|
||||
from conftest import TrackedContainer, find_free_port
|
||||
|
||||
from tests.conftest import TrackedContainer, find_free_port
|
||||
|
||||
|
||||
def test_secured_server(
|
||||
|
@@ -4,8 +4,9 @@
|
||||
import logging
|
||||
|
||||
import pytest # type: ignore
|
||||
from conftest import TrackedContainer
|
||||
from package_helper import CondaPackageHelper
|
||||
|
||||
from tests.conftest import TrackedContainer
|
||||
from tests.package_helper import CondaPackageHelper
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@@ -4,7 +4,8 @@
|
||||
import logging
|
||||
|
||||
import pytest # type: ignore
|
||||
from conftest import TrackedContainer
|
||||
|
||||
from tests.conftest import TrackedContainer
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@@ -41,8 +41,9 @@ import logging
|
||||
from typing import Callable, Iterable
|
||||
|
||||
import pytest # type: ignore
|
||||
from conftest import TrackedContainer
|
||||
from package_helper import CondaPackageHelper
|
||||
|
||||
from tests.conftest import TrackedContainer
|
||||
from tests.package_helper import CondaPackageHelper
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@@ -3,7 +3,7 @@
|
||||
|
||||
import logging
|
||||
|
||||
from conftest import TrackedContainer
|
||||
from tests.conftest import TrackedContainer
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@@ -2,9 +2,10 @@
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
import logging
|
||||
|
||||
from conftest import TrackedContainer
|
||||
from packaging import version # type: ignore
|
||||
|
||||
from tests.conftest import TrackedContainer
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@@ -7,7 +7,8 @@ from typing import Optional
|
||||
|
||||
import pytest # type: ignore
|
||||
import requests
|
||||
from conftest import TrackedContainer, find_free_port
|
||||
|
||||
from tests.conftest import TrackedContainer, find_free_port
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@@ -3,8 +3,8 @@
|
||||
|
||||
import logging
|
||||
|
||||
from conftest import TrackedContainer
|
||||
from images_hierarchy import get_test_dirs
|
||||
from tests.conftest import TrackedContainer
|
||||
from tests.images_hierarchy import get_test_dirs
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
import logging
|
||||
|
||||
from conftest import TrackedContainer
|
||||
from tests.conftest import TrackedContainer
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@@ -3,7 +3,7 @@
|
||||
|
||||
import logging
|
||||
|
||||
from conftest import TrackedContainer
|
||||
from tests.conftest import TrackedContainer
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@@ -5,7 +5,8 @@ import logging
|
||||
from pathlib import Path
|
||||
|
||||
import pytest # type: ignore
|
||||
from conftest import TrackedContainer
|
||||
|
||||
from tests.conftest import TrackedContainer
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
THIS_DIR = Path(__file__).parent.resolve()
|
||||
|
@@ -29,10 +29,11 @@ from collections import defaultdict
|
||||
from itertools import chain
|
||||
from typing import Any, Optional
|
||||
|
||||
from conftest import TrackedContainer
|
||||
from docker.models.containers import Container
|
||||
from tabulate import tabulate
|
||||
|
||||
from tests.conftest import TrackedContainer
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
import logging
|
||||
|
||||
from conftest import TrackedContainer
|
||||
from tests.conftest import TrackedContainer
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@@ -5,7 +5,8 @@ import argparse
|
||||
import logging
|
||||
|
||||
import plumbum
|
||||
from images_hierarchy import get_test_dirs
|
||||
|
||||
from tests.images_hierarchy import get_test_dirs
|
||||
|
||||
pytest = plumbum.local["pytest"]
|
||||
|
||||
|
@@ -3,7 +3,7 @@
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from conftest import TrackedContainer
|
||||
from tests.conftest import TrackedContainer
|
||||
|
||||
THIS_DIR = Path(__file__).parent.resolve()
|
||||
|
||||
|
@@ -3,7 +3,8 @@
|
||||
import logging
|
||||
|
||||
import pytest # type: ignore
|
||||
from conftest import TrackedContainer
|
||||
|
||||
from tests.conftest import TrackedContainer
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@@ -5,7 +5,8 @@ import logging
|
||||
from pathlib import Path
|
||||
|
||||
import pytest # type: ignore
|
||||
from conftest import TrackedContainer
|
||||
|
||||
from tests.conftest import TrackedContainer
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
THIS_DIR = Path(__file__).parent.resolve()
|
||||
|
Reference in New Issue
Block a user