Commit 7c8179e 1 parent 6009244 commit 7c8179e Copy full SHA for 7c8179e
File tree 1 file changed +35
-0
lines changed
1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ import os
2
+ from collections .abc import Iterable
3
+ from pathlib import Path
4
+
5
+ from testbook import testbook
6
+
7
+ TIMEOUT : int = 60 * 3 # 3 minutes
8
+
9
+ ROOT_DIRECTORY = Path (__file__ ).parent
10
+
11
+
12
+ def test_notebooks ():
13
+ for notebook_path in _get_notebooks ():
14
+ with testbook (notebook_path , execute = True , timeout = TIMEOUT ) as tb :
15
+ pass # we simply wish it to run without errors
16
+
17
+
18
+ # TODO: change this function to `from utils_for_tests import iterate_notebooks`, after we merge PR#109
19
+ def _get_notebooks () -> Iterable [str ]:
20
+ if os .environ .get ("SHOULD_TEST_ALL_FILES" , "" ) == "true" :
21
+ notebooks_to_test = _get_all_notebooks ()
22
+ else :
23
+ if os .environ .get ("HAS_ANY_IPYNB_CHANGED" , "" ) == "true" :
24
+ notebooks_to_test = os .environ .get ("LIST_OF_IPYNB_CHANGED" , "" ).split ()
25
+ else :
26
+ notebooks_to_test = []
27
+
28
+ return notebooks_to_test
29
+
30
+
31
+ def _get_all_notebooks (directory = ROOT_DIRECTORY ):
32
+ for root , dirs , files in os .walk (directory ):
33
+ for file in files :
34
+ if file .endswith (".ipynb" ):
35
+ yield os .path .join (root , file )
You can’t perform that action at this time.
0 commit comments