Skip to content

Commit ea1da55

Browse files
author
Varun Nair
committed
testing bug fix
testing example 07 bug fix
1 parent ba4a57d commit ea1da55

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/test_ex07.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import nbformat
2+
from nbclient import NotebookClient
3+
import os
4+
import pytest
5+
6+
def test_example07_first_cell_runs():
7+
notebook_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../examples/example_07/analysis.ipynb'))
8+
9+
with open(notebook_path, "r", encoding="utf-8") as f:
10+
nb = nbformat.read(f, as_version=4)
11+
12+
# Filter just the first code cell
13+
first_code_cell = next((cell for cell in nb.cells if cell.cell_type == "code"), None)
14+
15+
if not first_code_cell:
16+
pytest.fail("No code cell found in example07.ipynb")
17+
18+
# Create a minimal notebook with only the first cell
19+
nb_single = nbformat.v4.new_notebook()
20+
nb_single.cells = [first_code_cell]
21+
22+
try:
23+
client = NotebookClient(nb_single, timeout=60, kernel_name="pyiron")
24+
client.execute()
25+
except Exception as e:
26+
pytest.fail(f"First code cell in example07.analysis.ipynb failed: {e}")

0 commit comments

Comments
 (0)