mirror of
https://github.com/jupyter/docker-stacks.git
synced 2025-10-12 12:32:58 +00:00
Merge branch 'master' into asalikhov/py_codestyle
This commit is contained in:
@@ -8,13 +8,24 @@ import os
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def test_matplotlib(container):
|
||||
"""Test that matplotlib is able to plot a graph and write it as an image"""
|
||||
host_data_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data")
|
||||
@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")
|
||||
cont_data_dir = "/home/jovyan/data"
|
||||
test_file = "matplotlib_1.py"
|
||||
output_dir = "/tmp"
|
||||
LOGGER.info("Test that matplotlib is able to plot a graph and write it as an image ...")
|
||||
LOGGER.info(description)
|
||||
command = "sleep infinity"
|
||||
running_container = container.run(
|
||||
volumes={host_data_dir: {"bind": cont_data_dir, "mode": "ro"}},
|
||||
@@ -27,8 +38,7 @@ def test_matplotlib(container):
|
||||
LOGGER.debug(cmd.output.decode("utf-8"))
|
||||
# Checking if the file is generated
|
||||
# https://stackoverflow.com/a/15895594/4413446
|
||||
expected_file = f"{output_dir}/test.png"
|
||||
command = f"test -s {expected_file}"
|
||||
command = f"test -s {output_dir}/{expected_file}"
|
||||
cmd = running_container.exec_run(command)
|
||||
assert cmd.exit_code == 0, f"Command {command} failed"
|
||||
LOGGER.debug(cmd.output.decode("utf-8"))
|
||||
|
Reference in New Issue
Block a user