This repository has been archived by the owner on Jan 13, 2024. It is now read-only.
/
test_pyensae_flat2db3.py
96 lines (85 loc) · 2.5 KB
/
test_pyensae_flat2db3.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
"""
@brief test log(time=132s)
"""
import sys
import os
import unittest
import re
try:
import src
import pyquickhelper
except ImportError:
path = os.path.normpath(
os.path.abspath(
os.path.join(
os.path.split(__file__)[0],
"..",
"..")))
if path not in sys.path:
sys.path.append(path)
path = os.path.normpath(
os.path.abspath(
os.path.join(
os.path.split(__file__)[0],
"..",
"..",
"..",
"pyquickhelper",
"src")))
if path not in sys.path:
sys.path.append(path)
import src
import pyquickhelper
from pyquickhelper.ipythonhelper.notebook_helper import run_notebook
from pyquickhelper import get_temp_folder, fLOG
class TestNotebookRunnerFlat2Db3 (unittest.TestCase):
def test_notebook_runner_flat2db3(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
notebook = os.path.split(
__file__)[-1].replace(".ipynb", "").replace(".py", "")[5:]
temp = get_temp_folder(__file__, "temp_" + notebook)
nbfile = os.path.join(
temp,
"..",
"..",
"..",
"_doc",
"notebooks",
"%s.ipynb" %
notebook)
if not os.path.exists(nbfile):
raise FileNotFoundError(nbfile)
addpath = [os.path.normpath(os.path.join(temp, "..", "..", "..", "src")),
os.path.normpath(
os.path.join(
temp,
"..",
"..",
"..",
"..",
"pyquickhelper",
"src")),
os.path.normpath(
os.path.join(
temp,
"..",
"..",
"..",
"..",
"pymyinstall",
"src")),
]
outfile = os.path.join(temp, "out_notebook.ipynb")
assert not os.path.exists(outfile)
valid = lambda code: 'run_cmd("SQLiteSpy.exe velib_vanves.db3")' not in code
if "travis" in sys.executable:
return
out = run_notebook(nbfile, working_dir=temp, outfilename=outfile, additional_path=addpath,
valid=valid, fLOG=fLOG)
fLOG(out)
assert os.path.exists(outfile)
if __name__ == "__main__":
unittest.main()