Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# First we store the absolute directory of this script,
# then two directories above this,with the directory
# 'data' appended
PWD = Path(__file__).parent.absolute()
PWD = Path(__file__).parent.resolve()
DPATH = PWD.parent.parent / "data"

# 3: Give an identifying name for the refinement, similar
Expand Down
19 changes: 19 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
import json

# tests/conftest.py
import shutil
from pathlib import Path

import pytest

PROJECT_ROOT = Path(__file__).resolve().parents[1]
EXAMPLES_ROOT = PROJECT_ROOT / "docs" / "examples"


@pytest.fixture(scope="session")
def tmp_examples(tmp_path_factory):
"""Copy the entire examples/ tree into a temp directory once per
test session.

Returns the path to that copy.
"""
tmpdir = tmp_path_factory.mktemp("examples")
tmp_examples = tmpdir / "examples"
shutil.copytree(EXAMPLES_ROOT, tmp_examples)
yield tmp_examples


@pytest.fixture
def user_filesystem(tmp_path):
Expand Down
8 changes: 8 additions & 0 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import runpy


def test_all_examples(tmp_examples):
scripts = list(tmp_examples.rglob("**/solutions/diffpy-cmi/*.py"))
for script_path in scripts:
print(f"Testing {script_path.relative_to(tmp_examples)}")
runpy.run_path(str(script_path), run_name="__main__")
Loading