File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed
docs/examples/ch03NiModelling/solutions/diffpy-cmi Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change 3333# First we store the absolute directory of this script,
3434# then two directories above this,with the directory
3535# 'data' appended
36- PWD = Path (__file__ ).parent .absolute ()
36+ PWD = Path (__file__ ).parent .resolve ()
3737DPATH = PWD .parent .parent / "data"
3838
3939# 3: Give an identifying name for the refinement, similar
Original file line number Diff line number Diff line change 11import json
2+
3+ # tests/conftest.py
4+ import shutil
25from pathlib import Path
36
47import pytest
58
9+ PROJECT_ROOT = Path (__file__ ).resolve ().parents [1 ]
10+ EXAMPLES_ROOT = PROJECT_ROOT / "docs" / "examples"
11+
12+
13+ @pytest .fixture (scope = "session" )
14+ def tmp_examples (tmp_path_factory ):
15+ """Copy the entire examples/ tree into a temp directory once per
16+ test session.
17+
18+ Returns the path to that copy.
19+ """
20+ tmpdir = tmp_path_factory .mktemp ("examples" )
21+ tmp_examples = tmpdir / "examples"
22+ shutil .copytree (EXAMPLES_ROOT , tmp_examples )
23+ yield tmp_examples
24+
625
726@pytest .fixture
827def user_filesystem (tmp_path ):
Original file line number Diff line number Diff line change 1+ import runpy
2+
3+
4+ def test_all_examples (tmp_examples ):
5+ scripts = list (tmp_examples .rglob ("**/solutions/diffpy-cmi/*.py" ))
6+ for script_path in scripts :
7+ print (f"Testing { script_path .relative_to (tmp_examples )} " )
8+ runpy .run_path (str (script_path ), run_name = "__main__" )
You can’t perform that action at this time.
0 commit comments