File tree Expand file tree Collapse file tree 3 files changed +32
-29
lines changed Expand file tree Collapse file tree 3 files changed +32
-29
lines changed Original file line number Diff line number Diff line change 11import json
2- import shutil
32from pathlib import Path
43
54import matplotlib
65import pytest
76
8- PROJECT_ROOT = Path (__file__ ).resolve ().parents [1 ]
9- EXAMPLES_ROOT = PROJECT_ROOT / "docs" / "examples"
10-
11-
12- @pytest .fixture (scope = "session" )
13- def tmp_examples (tmp_path_factory ):
14- """Copy the entire examples/ tree into a temp directory once per
15- test session.
16-
17- Returns the path to that copy.
18- """
19- tmpdir = tmp_path_factory .mktemp ("examples" )
20- tmp_examples = tmpdir / "examples"
21- shutil .copytree (EXAMPLES_ROOT , tmp_examples )
22- yield tmp_examples
23-
247
258@pytest .fixture (scope = "session" )
269def example_cases (tmp_path_factory ):
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import runpy
2+ import shutil
3+ from pathlib import Path
4+
5+ import pytest
6+
7+ PROJECT_ROOT = Path (__file__ ).resolve ().parents [1 ]
8+ EXAMPLES_ROOT = PROJECT_ROOT / "docs" / "examples"
9+
10+
11+ @pytest .fixture (scope = "session" )
12+ def tmp_examples (tmp_path_factory ):
13+ """Copy the entire examples/ tree into a temp directory once per
14+ test session.
15+
16+ Returns the path to that copy.
17+ """
18+ tmpdir = tmp_path_factory .mktemp ("examples" )
19+ tmp_examples = tmpdir / "examples"
20+ shutil .copytree (EXAMPLES_ROOT , tmp_examples )
21+ yield tmp_examples
22+
23+
24+ def test_all_examples (tmp_examples ):
25+ """Run all example scripts to ensure they execute without error."""
26+ scripts = list (tmp_examples .rglob ("**/solutions/diffpy-cmi/*.py" ))
27+ # sort list so that fitBulkNi.py runs first
28+ scripts .sort (key = lambda s : 0 if s .name == "fitBulkNi.py" else 1 )
29+ for script in scripts :
30+ script_relative_path = script .relative_to (tmp_examples )
31+ print (f"Testing { script_relative_path } " )
32+ runpy .run_path (str (script ), run_name = "__main__" )
You can’t perform that action at this time.
0 commit comments