forked from pielstroem/Topics
-
Notifications
You must be signed in to change notification settings - Fork 13
/
integration_test.py
71 lines (65 loc) · 2.75 KB
/
integration_test.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
from subprocess import check_output, STDOUT, CalledProcessError
from nose.plugins.skip import SkipTest
from pathlib import Path
import logging
import re
project_path = Path(__file__).absolute().parent.parent
def jupyter_integration_test():
"""
Integration test notebook (via Jupyter)
"""
#Test Introduction
try:
check_output(["jupyter-nbconvert", "--execute",
"--log-level=ERROR",
"--ExecutePreprocessor.iopub_timeout=30",
"--ExecutePreprocessor.timeout=None",
str(Path(project_path, "Introduction.ipynb"))],
stderr=STDOUT, universal_newlines=True)
except FileNotFoundError as e:
raise SkipTest("jupyter-nbconvert not found. Cannot run integration test. "
+ str(e))
except CalledProcessError as e:
message = e.output
cellinfo = re.search('nbconvert.preprocessors.execute.CellExecutionError: (.+)$',
message, re.MULTILINE | re.DOTALL)
if cellinfo:
message = cellinfo.group(1)
logging.error(message)
#Test Gensim
try:
check_output(["jupyter-nbconvert", "--execute",
"--log-level=ERROR",
"--ExecutePreprocessor.iopub_timeout=30",
"--ExecutePreprocessor.timeout=None",
str(Path(project_path, "IntegrationTest_txt_gensim.ipynb"))],
stderr=STDOUT, universal_newlines=True)
except FileNotFoundError as e:
raise SkipTest("jupyter-nbconvert not found. Cannot run integration test. "
+ str(e))
except CalledProcessError as e:
message = e.output
cellinfo = re.search('nbconvert.preprocessors.execute.CellExecutionError: (.+)$',
message, re.MULTILINE | re.DOTALL)
if cellinfo:
message = cellinfo.group(1)
logging.error(message)
#Test Mallet
try:
check_output(["jupyter-nbconvert", "--execute",
"--log-level=ERROR",
"--ExecutePreprocessor.iopub_timeout=30",
"--ExecutePreprocessor.timeout=None",
str(Path(project_path, "Mallet.ipynb"))],
stderr=STDOUT, universal_newlines=True)
except FileNotFoundError as e:
raise SkipTest("jupyter-nbconvert not found. Cannot run integration test. "
+ str(e))
except CalledProcessError as e:
message = e.output
cellinfo = re.search('nbconvert.preprocessors.execute.CellExecutionError: (.+)$',
message, re.MULTILINE | re.DOTALL)
if cellinfo:
message = cellinfo.group(1)
logging.error(message)
raise