mirror of
https://github.com/jupyter/docker-stacks.git
synced 2025-10-08 10:34:06 +00:00
Fix style in tests
This commit is contained in:
@@ -7,6 +7,7 @@ import pytest
|
||||
import os
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
THIS_DIR = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -16,7 +17,7 @@ LOGGER = logging.getLogger(__name__)
|
||||
)
|
||||
def test_nbconvert(container, test_file):
|
||||
"""Check if Spark notebooks can be executed"""
|
||||
host_data_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data")
|
||||
host_data_dir = os.path.join(THIS_DIR, "data")
|
||||
cont_data_dir = "/home/jovyan/data"
|
||||
output_dir = "/tmp"
|
||||
timeout_ms = 600
|
||||
|
@@ -8,7 +8,7 @@ LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"package_manager, cmd",
|
||||
"package_manager, version_arg",
|
||||
[
|
||||
("apt", "--version"),
|
||||
("conda", "--version"),
|
||||
@@ -17,13 +17,14 @@ LOGGER = logging.getLogger(__name__)
|
||||
("pip", "--version"),
|
||||
],
|
||||
)
|
||||
def test_package_manager(container, package_manager, cmd):
|
||||
def test_package_manager(container, package_manager, version_arg):
|
||||
"""Test the notebook start-notebook script"""
|
||||
LOGGER.info(
|
||||
f"Test that the package manager {package_manager} is working properly ..."
|
||||
)
|
||||
c = container.run(
|
||||
tty=True, command=["start.sh", "bash", "-c", f"{package_manager} {cmd}"]
|
||||
tty=True,
|
||||
command=["start.sh", "bash", "-c", f"{package_manager} {version_arg}"]
|
||||
)
|
||||
rv = c.wait(timeout=5)
|
||||
logs = c.logs(stdout=True).decode("utf-8")
|
||||
|
@@ -9,7 +9,8 @@ LOGGER = logging.getLogger(__name__)
|
||||
def test_pandoc(container):
|
||||
"""Pandoc shall be able to convert MD to HTML."""
|
||||
c = container.run(
|
||||
tty=True, command=["start.sh", "bash", "-c", 'echo "**BOLD**" | pandoc']
|
||||
tty=True,
|
||||
command=["start.sh", "bash", "-c", 'echo "**BOLD**" | pandoc']
|
||||
)
|
||||
c.wait(timeout=10)
|
||||
logs = c.logs(stdout=True).decode("utf-8")
|
||||
|
@@ -8,7 +8,11 @@ LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"env,expected_server", [(["JUPYTER_ENABLE_LAB=yes"], "lab"), (None, "notebook"), ],
|
||||
"env,expected_server",
|
||||
[
|
||||
(["JUPYTER_ENABLE_LAB=yes"], "lab"),
|
||||
(None, "notebook"),
|
||||
],
|
||||
)
|
||||
def test_start_notebook(container, http_client, env, expected_server):
|
||||
"""Test the notebook start-notebook script"""
|
||||
|
@@ -33,10 +33,10 @@ def docker_client():
|
||||
@pytest.fixture(scope='session')
|
||||
def image_name():
|
||||
"""Image name to test"""
|
||||
return os.getenv('TEST_IMAGE', 'jupyter/base-notebook')
|
||||
return os.getenv('TEST_IMAGE')
|
||||
|
||||
|
||||
class TrackedContainer(object):
|
||||
class TrackedContainer:
|
||||
"""Wrapper that collects docker container configuration and delays
|
||||
container creation/execution.
|
||||
|
||||
|
@@ -9,7 +9,8 @@ def test_julia(container):
|
||||
"""Basic julia test"""
|
||||
LOGGER.info("Test that julia is correctly installed ...")
|
||||
running_container = container.run(
|
||||
tty=True, command=["start.sh", "bash", "-c", "sleep infinity"]
|
||||
tty=True,
|
||||
command=["start.sh", "bash", "-c", "sleep infinity"]
|
||||
)
|
||||
command = "julia --version"
|
||||
cmd = running_container.exec_run(command)
|
||||
|
@@ -10,7 +10,8 @@ def test_inkscape(container):
|
||||
"""Inkscape shall be installed to be able to convert SVG files."""
|
||||
LOGGER.info("Test that inkscape is working by printing its version ...")
|
||||
c = container.run(
|
||||
tty=True, command=["start.sh", "bash", "-c", "inkscape --version"]
|
||||
tty=True,
|
||||
command=["start.sh", "bash", "-c", "inkscape --version"]
|
||||
)
|
||||
c.wait(timeout=10)
|
||||
logs = c.logs(stdout=True).decode("utf-8")
|
||||
|
@@ -7,18 +7,24 @@ import pytest
|
||||
import os
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
THIS_DIR = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_file, output_format,", [
|
||||
("notebook_math", "pdf"), ("notebook_math", "html"),
|
||||
("notebook_svg", "pdf"), ("notebook_svg", "html"),
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
"test_file, output_format",
|
||||
[
|
||||
("notebook_math", "pdf"),
|
||||
("notebook_math", "html"),
|
||||
("notebook_svg", "pdf"),
|
||||
("notebook_svg", "html"),
|
||||
],
|
||||
)
|
||||
def test_nbconvert(container, test_file, output_format):
|
||||
"""Check if nbconvert is able to convert a notebook file"""
|
||||
host_data_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data")
|
||||
host_data_dir = os.path.join(THIS_DIR, "data")
|
||||
cont_data_dir = "/home/jovyan/data"
|
||||
output_dir = "/tmp"
|
||||
LOGGER.info(f"Test that the example notebook {test_file} can be converted to {output_format.upper()} ...")
|
||||
LOGGER.info(f"Test that the example notebook {test_file} can be converted to {output_format} ...")
|
||||
command = f"jupyter nbconvert {cont_data_dir}/{test_file}.ipynb --output-dir {output_dir} --to {output_format}"
|
||||
c = container.run(
|
||||
volumes={host_data_dir: {"bind": cont_data_dir, "mode": "ro"}},
|
||||
|
@@ -1,5 +1,6 @@
|
||||
docker
|
||||
myst-parser
|
||||
packaging
|
||||
plumbum
|
||||
pre-commit
|
||||
pytest
|
||||
|
@@ -26,7 +26,8 @@ def test_check_extension(container, extension):
|
||||
"""
|
||||
LOGGER.info(f"Checking the extension: {extension} ...")
|
||||
c = container.run(
|
||||
tty=True, command=["start.sh", "jupyter", "labextension", "check", extension]
|
||||
tty=True,
|
||||
command=["start.sh", "jupyter", "labextension", "check", extension]
|
||||
)
|
||||
rv = c.wait(timeout=10)
|
||||
logs = c.logs(stdout=True).decode("utf-8")
|
||||
|
@@ -7,23 +7,23 @@ import pytest
|
||||
import os
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
THIS_DIR = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_file,expected_file,description",
|
||||
@pytest.mark.parametrize(
|
||||
"test_file,expected_file,description",
|
||||
[
|
||||
("matplotlib_1.py", "test.png",
|
||||
"Test that matplotlib is able to plot a graph and write it as an image ..."),
|
||||
("matplotlib_fonts_1.py", "test_fonts.png",
|
||||
"Test cm-super latex labels in matplotlib ...")
|
||||
])
|
||||
("matplotlib_1.py", "test.png", "Test that matplotlib is able to plot a graph and write it as an image ..."),
|
||||
("matplotlib_fonts_1.py", "test_fonts.png", "Test cm-super latex labels in matplotlib ...")
|
||||
]
|
||||
)
|
||||
def test_matplotlib(container, test_file, expected_file, description):
|
||||
"""Various tests performed on matplotlib
|
||||
|
||||
- Test that matplotlib is able to plot a graph and write it as an image
|
||||
- Test matplotlib latex fonts, which depend on the cm-super package
|
||||
"""
|
||||
host_data_dir = os.path.join(os.path.dirname(
|
||||
os.path.realpath(__file__)), "data")
|
||||
host_data_dir = os.path.join(THIS_DIR, "data")
|
||||
cont_data_dir = "/home/jovyan/data"
|
||||
output_dir = "/tmp"
|
||||
LOGGER.info(description)
|
||||
|
@@ -50,7 +50,8 @@ class CondaPackageHelper:
|
||||
"""Start the TrackedContainer and return an instance of a running container"""
|
||||
LOGGER.info(f"Starting container {container.image_name} ...")
|
||||
return container.run(
|
||||
tty=True, command=["start.sh", "bash", "-c", "sleep infinity"]
|
||||
tty=True,
|
||||
command=["start.sh", "bash", "-c", "sleep infinity"]
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
|
Reference in New Issue
Block a user