Skip to content

Commit

Permalink
add testbook to automate re-running jupyter notebooks and see if they…
Browse files Browse the repository at this point in the history
… still seem to work
  • Loading branch information
a.pirogov committed Aug 16, 2023
1 parent ce307d0 commit 646887b
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
21 changes: 20 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ hypothesis = "^6.58.0"
frozendict = "^2.3.4"
# somesy = {path = "../somesy", develop = true}
notebook = "^7.0.2"
testbook = "^0.4.2"

[tool.poetry.group.docs.dependencies]
mkdocs = "^1.4.2"
Expand Down
24 changes: 24 additions & 0 deletions tests/zz_docs/test_notebooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import os
from pathlib import Path

import pytest
from testbook import testbook


@pytest.fixture(scope="module")
def nb_cwd():
"""Fixture to change CWD to location of notebooks."""
old = os.getcwd()
nb_dir = Path("./docs/notebooks")
assert nb_dir.is_dir()
os.chdir(nb_dir)
yield None
os.chdir(old)


def test_notebooks_execute(nb_cwd):
"""Test that all tutorial notebooks run through without exceptions."""
for nb_file in Path(".").glob("*.ipynb"):
with testbook(nb_file, execute=True):
# just check it runs fine
print(f"Notebook {nb_file} run complete.")

0 comments on commit 646887b

Please sign in to comment.