-
Notifications
You must be signed in to change notification settings - Fork 55
/
testTutorials.py
36 lines (29 loc) · 1.13 KB
/
testTutorials.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
import logging
import shutil
from pathlib import Path
from tempfile import TemporaryDirectory
from notebookstestcase import _PYGSTI_ROOT, notebooks_in_path, _make_test
# All tutorials to be tested are under this directory
_TUTORIALS_ROOT = _PYGSTI_ROOT / 'jupyter_notebooks' / 'Tutorials'
# File resources to be copied to the workdir before testing
_TUTORIAL_FILES = [
'tutorial_files/MyCircuits.txt',
'tutorial_files/timestamped_dataset.txt',
'tutorial_files/Example_GST_Data'
]
def test_tutorials():
logging.getLogger('traitlets').setLevel(logging.CRITICAL)
with TemporaryDirectory() as tmp:
tmp_path = Path(tmp)
# Copy tutorial file resources
for f_path in _TUTORIAL_FILES:
src = _TUTORIALS_ROOT / f_path
dest = tmp_path / f_path
dest.parent.mkdir(parents=True, exist_ok=True)
if src.is_dir():
shutil.copytree(src, dest)
else:
shutil.copy(src, dest)
# Emit a test for each notebook
for nb_path in notebooks_in_path(_TUTORIALS_ROOT):
yield _make_test(nb_path, tmp_path, _TUTORIALS_ROOT)