Skip to content

Commit aee3cbb

Browse files
authored
Merge pull request #1388 from mathbunnyru/asalikhov/tests_style
Fix style in tests
2 parents 5211732 + 4828b41 commit aee3cbb

File tree

12 files changed

+45
-27
lines changed

12 files changed

+45
-27
lines changed

all-spark-notebook/test/test_spark_notebooks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import os
88

99
LOGGER = logging.getLogger(__name__)
10+
THIS_DIR = os.path.dirname(os.path.realpath(__file__))
1011

1112

1213
@pytest.mark.parametrize(
@@ -16,7 +17,7 @@
1617
)
1718
def test_nbconvert(container, test_file):
1819
"""Check if Spark notebooks can be executed"""
19-
host_data_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data")
20+
host_data_dir = os.path.join(THIS_DIR, "data")
2021
cont_data_dir = "/home/jovyan/data"
2122
output_dir = "/tmp"
2223
timeout_ms = 600

base-notebook/test/test_package_managers.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
@pytest.mark.parametrize(
11-
"package_manager, cmd",
11+
"package_manager, version_arg",
1212
[
1313
("apt", "--version"),
1414
("conda", "--version"),
@@ -17,13 +17,14 @@
1717
("pip", "--version"),
1818
],
1919
)
20-
def test_package_manager(container, package_manager, cmd):
20+
def test_package_manager(container, package_manager, version_arg):
2121
"""Test the notebook start-notebook script"""
2222
LOGGER.info(
2323
f"Test that the package manager {package_manager} is working properly ..."
2424
)
2525
c = container.run(
26-
tty=True, command=["start.sh", "bash", "-c", f"{package_manager} {cmd}"]
26+
tty=True,
27+
command=["start.sh", "bash", "-c", f"{package_manager} {version_arg}"]
2728
)
2829
rv = c.wait(timeout=5)
2930
logs = c.logs(stdout=True).decode("utf-8")

base-notebook/test/test_pandoc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
def test_pandoc(container):
1010
"""Pandoc shall be able to convert MD to HTML."""
1111
c = container.run(
12-
tty=True, command=["start.sh", "bash", "-c", 'echo "**BOLD**" | pandoc']
12+
tty=True,
13+
command=["start.sh", "bash", "-c", 'echo "**BOLD**" | pandoc']
1314
)
1415
c.wait(timeout=10)
1516
logs = c.logs(stdout=True).decode("utf-8")

base-notebook/test/test_start_container.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88

99

1010
@pytest.mark.parametrize(
11-
"env,expected_server", [(["JUPYTER_ENABLE_LAB=yes"], "lab"), (None, "notebook"), ],
11+
"env,expected_server",
12+
[
13+
(["JUPYTER_ENABLE_LAB=yes"], "lab"),
14+
(None, "notebook"),
15+
],
1216
)
1317
def test_start_notebook(container, http_client, env, expected_server):
1418
"""Test the notebook start-notebook script"""

conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ def docker_client():
3333
@pytest.fixture(scope='session')
3434
def image_name():
3535
"""Image name to test"""
36-
return os.getenv('TEST_IMAGE', 'jupyter/base-notebook')
36+
return os.getenv('TEST_IMAGE')
3737

3838

39-
class TrackedContainer(object):
39+
class TrackedContainer:
4040
"""Wrapper that collects docker container configuration and delays
4141
container creation/execution.
4242

datascience-notebook/test/test_julia.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ def test_julia(container):
99
"""Basic julia test"""
1010
LOGGER.info("Test that julia is correctly installed ...")
1111
running_container = container.run(
12-
tty=True, command=["start.sh", "bash", "-c", "sleep infinity"]
12+
tty=True,
13+
command=["start.sh", "bash", "-c", "sleep infinity"]
1314
)
1415
command = "julia --version"
1516
cmd = running_container.exec_run(command)

minimal-notebook/test/test_inkscape.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ def test_inkscape(container):
1010
"""Inkscape shall be installed to be able to convert SVG files."""
1111
LOGGER.info("Test that inkscape is working by printing its version ...")
1212
c = container.run(
13-
tty=True, command=["start.sh", "bash", "-c", "inkscape --version"]
13+
tty=True,
14+
command=["start.sh", "bash", "-c", "inkscape --version"]
1415
)
1516
c.wait(timeout=10)
1617
logs = c.logs(stdout=True).decode("utf-8")

minimal-notebook/test/test_nbconvert.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,24 @@
77
import os
88

99
LOGGER = logging.getLogger(__name__)
10+
THIS_DIR = os.path.dirname(os.path.realpath(__file__))
1011

1112

12-
@pytest.mark.parametrize("test_file, output_format,", [
13-
("notebook_math", "pdf"), ("notebook_math", "html"),
14-
("notebook_svg", "pdf"), ("notebook_svg", "html"),
15-
])
13+
@pytest.mark.parametrize(
14+
"test_file, output_format",
15+
[
16+
("notebook_math", "pdf"),
17+
("notebook_math", "html"),
18+
("notebook_svg", "pdf"),
19+
("notebook_svg", "html"),
20+
],
21+
)
1622
def test_nbconvert(container, test_file, output_format):
1723
"""Check if nbconvert is able to convert a notebook file"""
18-
host_data_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data")
24+
host_data_dir = os.path.join(THIS_DIR, "data")
1925
cont_data_dir = "/home/jovyan/data"
2026
output_dir = "/tmp"
21-
LOGGER.info(f"Test that the example notebook {test_file} can be converted to {output_format.upper()} ...")
27+
LOGGER.info(f"Test that the example notebook {test_file} can be converted to {output_format} ...")
2228
command = f"jupyter nbconvert {cont_data_dir}/{test_file}.ipynb --output-dir {output_dir} --to {output_format}"
2329
c = container.run(
2430
volumes={host_data_dir: {"bind": cont_data_dir, "mode": "ro"}},

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
docker
22
myst-parser
3+
packaging
34
plumbum
45
pre-commit
56
pytest

scipy-notebook/test/test_extensions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ def test_check_extension(container, extension):
2626
"""
2727
LOGGER.info(f"Checking the extension: {extension} ...")
2828
c = container.run(
29-
tty=True, command=["start.sh", "jupyter", "labextension", "check", extension]
29+
tty=True,
30+
command=["start.sh", "jupyter", "labextension", "check", extension]
3031
)
3132
rv = c.wait(timeout=10)
3233
logs = c.logs(stdout=True).decode("utf-8")

0 commit comments

Comments
 (0)