mirror of
https://github.com/jupyter/docker-stacks.git
synced 2025-10-16 22:42:57 +00:00
Better tests directory structure (#2231)
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
# Copyright (c) Jupyter Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
import pytest # type: ignore
|
||||
|
||||
from tests.utils.tracked_container import TrackedContainer
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
THIS_DIR = Path(__file__).parent.resolve()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_file", ["notebook_math", "notebook_svg"])
|
||||
@pytest.mark.parametrize("output_format", ["pdf", "html"])
|
||||
def test_nbconvert(
|
||||
container: TrackedContainer, test_file: str, output_format: str
|
||||
) -> None:
|
||||
"""Check if nbconvert is able to convert a notebook file"""
|
||||
host_data_dir = 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} ..."
|
||||
)
|
||||
command = f"jupyter nbconvert {cont_data_dir}/{test_file}.ipynb --output-dir {output_dir} --to {output_format}"
|
||||
logs = container.run_and_wait(
|
||||
timeout=30,
|
||||
volumes={str(host_data_dir): {"bind": cont_data_dir, "mode": "ro"}},
|
||||
tty=True,
|
||||
command=["bash", "-c", command],
|
||||
)
|
||||
expected_file = f"{output_dir}/{test_file}.{output_format}"
|
||||
assert expected_file in logs, f"Expected file {expected_file} not generated"
|
Reference in New Issue
Block a user