Skip to content

Commit ad69c8f

Browse files
committed
actually run the tutorials
1 parent 854a5ea commit ad69c8f

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

test_tutorials/test_tutorials.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@
55
import os
66
import pytest
77

8-
# ROOT.gROOT.SetBatch(True)
8+
ROOT.gROOT.SetBatch(True)
99

10-
tutorial_dir = pathlib.Path(str(ROOT.gROOT.GetTutorialDir())) or pathlib.Path(ROOT.__file__).parent.parent.parent / "tutorials"
10+
tutorial_dir = pathlib.Path(str(ROOT.gROOT.GetTutorialDir()))
1111
tutorials = list(tutorial_dir.rglob("*.py"))
1212

1313

14-
@pytest.mark.parametrize("tutorial", tutorials)
14+
def test_tutorials_are_detected():
15+
assert len(tutorials) > 0
16+
17+
@pytest.mark.parametrize("tutorial", tutorials, ids=lambda p: p.name)
1518
def test_tutorial(tutorial):
16-
# subprocess.run([sys.executable, str(tutorial)], check=True)
17-
print(f"Running tutorial: {tutorial}")
18-
assert len(tutorials) > 0
19+
env = dict(**os.environ)
20+
# force matplotlib to use a non-GUI backend
21+
env["MPLBACKEND"] = "Agg"
22+
subprocess.run([sys.executable, str(tutorial)], check=True, env=env)

0 commit comments

Comments
 (0)