Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions requirements_tests.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pytest

testbook
nbformat
torch
torchvision
galois
Expand Down
20 changes: 20 additions & 0 deletions tests/test_no_errors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import os

import nbformat

from utils_for_tests import iterate_notebooks


def test_no_errors_in_notebooks() -> None:
for notebook in iterate_notebooks():
with open(notebook) as f:
notebook_data = nbformat.read(f, nbformat.NO_CONVERT)

for index, cell in enumerate(notebook_data["cells"]):
outputs = cell.get("outputs")
if outputs is None:
continue

assert not any(
output.get("output_type") == "error" for output in cell["outputs"]
), f"Cell #{index} in {os.path.basename(notebook)} has an output error"
2 changes: 1 addition & 1 deletion tests/utils_for_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def _get_all_notebooks(
directory: Path = ROOT_DIRECTORY, suffix: str = ".ipynb"
) -> list[str]:
return [
file
f"{root}/{file}"
for root, _, files in os.walk(directory)
for file in files
if file.endswith(suffix)
Expand Down
Loading