Skip to content

Fix style in tests #1388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion all-spark-notebook/test/test_spark_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import os

LOGGER = logging.getLogger(__name__)
THIS_DIR = os.path.dirname(os.path.realpath(__file__))


@pytest.mark.parametrize(
Expand All @@ -16,7 +17,7 @@
)
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
Expand Down
7 changes: 4 additions & 3 deletions base-notebook/test/test_package_managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


@pytest.mark.parametrize(
"package_manager, cmd",
"package_manager, version_arg",
[
("apt", "--version"),
("conda", "--version"),
Expand All @@ -17,13 +17,14 @@
("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")
Expand Down
3 changes: 2 additions & 1 deletion base-notebook/test/test_pandoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
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")
Expand Down
6 changes: 5 additions & 1 deletion base-notebook/test/test_start_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@


@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"""
Expand Down
4 changes: 2 additions & 2 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
3 changes: 2 additions & 1 deletion datascience-notebook/test/test_julia.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion minimal-notebook/test/test_inkscape.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
18 changes: 12 additions & 6 deletions minimal-notebook/test/test_nbconvert.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,24 @@
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"}},
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
docker
myst-parser
packaging
plumbum
pre-commit
pytest
Expand Down
3 changes: 2 additions & 1 deletion scipy-notebook/test/test_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
18 changes: 9 additions & 9 deletions scipy-notebook/test/test_matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
import os

LOGGER = logging.getLogger(__name__)
THIS_DIR = os.path.dirname(os.path.realpath(__file__))


@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 ...")
])
@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 ...")
]
)
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)
Expand Down
3 changes: 2 additions & 1 deletion test/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def start_container(container):
"""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
Expand Down