File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change
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 } " )
You can’t perform that action at this time.
0 commit comments