Skip to content

Commit 1f96075

Browse files
committed
test: Check python notebooks with pytest
1 parent f096f90 commit 1f96075

File tree

4 files changed

+1639
-117
lines changed

4 files changed

+1639
-117
lines changed

.github/change-filters.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ python: &python
1919
- "impl/py/**"
2020
- "pyproject.toml"
2121
- "uv.lock"
22+
- "examples/**.py"
23+
- "examples/**.ipynb"

impl/py/tests/test_examples.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""Tests validating the files in the repo's `examples` directory."""
2+
3+
import pytest
4+
from pathlib import Path
5+
6+
REPO_ROOT = Path(__file__).parent.parent.parent.parent
7+
notebook_files = list((REPO_ROOT / "examples").glob("**/*.ipynb"))
8+
9+
print(notebook_files)
10+
11+
12+
@pytest.mark.parametrize("notebook", notebook_files)
13+
def test_example_notebooks(nb_regression, notebook: Path):
14+
print("Notebook:", notebook)
15+
nb_regression.diff_ignore += (
16+
"/metadata/language_info/version",
17+
"/cells/*/outputs/*/data/image/png",
18+
)
19+
nb_regression.check(notebook)

pyproject.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ members = ["impl/py"]
44
[dependency-groups]
55
dev = [{ include-group = "lint" }, { include-group = "test" }]
66
lint = ["pre-commit ~=4.3", "ruff ~=0.12.10", "mypy ~=1.17"]
7-
test = ["pytest ~=8.4", "pytest-cov ~=6.2", "mypy ~=1.17"]
7+
test = [
8+
"ipykernel ~=6.29",
9+
"pytest ~=8.4",
10+
"pytest-cov ~=6.2",
11+
"pytest-notebook ~=0.10.0",
12+
"mypy ~=1.17",
13+
]
814

915
[tool.mypy]
1016
strict = true

0 commit comments

Comments
 (0)