mirror of
https://github.com/jupyter/docker-stacks.git
synced 2025-10-13 21:12:57 +00:00
Add a way to easily test units
This commit is contained in:
@@ -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",
|
||||
[
|
||||
("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)
|
||||
|
@@ -1,32 +0,0 @@
|
||||
# Copyright (c) Jupyter Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
import logging
|
||||
|
||||
import pytest
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"name,command_list",
|
||||
[
|
||||
(
|
||||
"Sum series",
|
||||
[
|
||||
"import pandas as pd",
|
||||
"import numpy as np",
|
||||
"np.random.seed(0)",
|
||||
"print(pd.Series(np.random.randint(0, 7, size=10)).sum())"
|
||||
]
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_pandas(container, name, command_list):
|
||||
"""Basic pandas tests"""
|
||||
LOGGER.info(f"Testing pandas: {name} ...")
|
||||
command = ';'.join(command_list)
|
||||
c = container.run(tty=True, command=["start.sh", "python", "-c", command])
|
||||
rv = c.wait(timeout=30)
|
||||
assert rv == 0 or rv["StatusCode"] == 0, f"Command {command} failed"
|
||||
logs = c.logs(stdout=True).decode("utf-8")
|
||||
LOGGER.debug(logs)
|
9
scipy-notebook/test/units/unit_pandas.py
Normal file
9
scipy-notebook/test/units/unit_pandas.py
Normal file
@@ -0,0 +1,9 @@
|
||||
# Copyright (c) Jupyter Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
|
||||
np.random.seed(0)
|
||||
print(pd.Series(np.random.randint(0, 7, size=10)).sum())
|
Reference in New Issue
Block a user