Skip to content

Commit a0c8144

Browse files
committed
add support for testing .md notebooks
1 parent dd6405f commit a0c8144

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ gpxpy
1414
ipykernel
1515
jenkspy
1616
jupyter
17+
jupytext
1718
matplotlib
1819
mypy
1920
nbconvert

tests/selenium/test_selenium.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def find_notebooks():
1818
pattern = os.path.join(path, "..", "..", "examples", "*.ipynb")
1919
files = glob.glob(pattern)
2020
files = [f for f in files if not f.endswith(".nbconvert.ipynb")]
21+
files.extend(glob.glob(os.path.join(path, "..", "..", "docs", "*.md")))
2122
if files:
2223
return files
2324
else:
@@ -42,18 +43,29 @@ def test_notebook(filepath, driver):
4243

4344
def get_notebook_html(filepath_notebook):
4445
"""Store iframes from a notebook in html files, remove them when done."""
45-
# run the notebook to make sure the output is up-to-date
46-
subprocess.run(
47-
[
48-
"jupyter",
49-
"nbconvert",
50-
"--to",
51-
"notebook",
52-
"--execute",
53-
filepath_notebook,
54-
]
55-
)
56-
filepath_notebook = filepath_notebook.replace(".ipynb", ".nbconvert.ipynb")
46+
if filepath_notebook.endswith(".ipynb"):
47+
subprocess.run(
48+
[
49+
"jupyter",
50+
"nbconvert",
51+
"--to",
52+
"notebook",
53+
"--execute",
54+
filepath_notebook,
55+
]
56+
)
57+
filepath_notebook = filepath_notebook.replace(".ipynb", ".nbconvert.ipynb")
58+
else:
59+
subprocess.run(
60+
[
61+
"jupytext",
62+
"--to",
63+
"notebook",
64+
"--execute",
65+
filepath_notebook,
66+
]
67+
)
68+
filepath_notebook = filepath_notebook.replace(".md", ".ipynb")
5769

5870
html_exporter = nbconvert.HTMLExporter()
5971
body, _ = html_exporter.from_filename(filepath_notebook)

0 commit comments

Comments
 (0)