forked from nanshe-org/nanshe_workflow
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_nanshe_workflow.py
executable file
·54 lines (42 loc) · 1.23 KB
/
test_nanshe_workflow.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python
import contextlib
import os
import sys
import unittest
import nbconvert
import nbconvert.nbconvertapp
@contextlib.contextmanager
def sys_args(argv):
sys.argv, argv = argv, sys.argv
yield
sys.argv, argv = argv, sys.argv
class TestNansheWorkflow(unittest.TestCase):
def testRunNansheIPython(self):
sdir = os.path.abspath(os.path.curdir)
nb_filenames = [
"nanshe_ipython.ipynb",
]
timeout_opt = (
"--ExecutePreprocessor.timeout=%s" %
os.environ.get("NB_EXE_TIMEOUT", "120")
)
for each_nb_filename in nb_filenames:
argv = (
"jupyter",
"nbconvert",
"--ExecutePreprocessor.kernel_name=python%i" % sys.version_info[0]
)
if timeout_opt:
argv += (timeout_opt,)
argv += (
"--to",
"notebook",
"--stdout",
"--execute",
"%s/nanshe_ipython.ipynb" % sdir
)
with sys_args(argv):
os.environ["TEST_NOTEBOOKS"] = "true"
nbconvert.nbconvertapp.main()
if __name__ == '__main__':
unittest.main()