Skip to content

Commit 8cff34c

Browse files
committed
Add confests
1 parent 7962a0d commit 8cff34c

3 files changed

Lines changed: 28 additions & 7 deletions

File tree

conda-recipe/run_test.py

Lines changed: 0 additions & 5 deletions
This file was deleted.

pytest.ini

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/conftest.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
from pathlib import Path
33

44
import pytest
5+
import six
6+
import diffpy.pdffit2.output # assuming this is the correct import path
57

68

9+
import diffpy.pdffit2
10+
711
@pytest.fixture
812
def user_filesystem(tmp_path):
913
base_dir = Path(tmp_path)
@@ -17,3 +21,27 @@ def user_filesystem(tmp_path):
1721
json.dump(home_config_data, f)
1822

1923
yield tmp_path
24+
25+
@pytest.fixture
26+
def datafile():
27+
"""Fixture to dynamically load any test file."""
28+
29+
def _load(filename):
30+
return "tests/testdata/" + filename
31+
32+
return _load
33+
34+
@pytest.fixture
35+
def capture_output():
36+
"""Capture output from pdffit2 engine produced in function call."""
37+
38+
def _capture(f, *args, **kwargs):
39+
savestdout = diffpy.pdffit2.output.stdout
40+
fp = six.StringIO()
41+
diffpy.pdffit2.redirect_stdout(fp)
42+
try:
43+
f(*args, **kwargs)
44+
finally:
45+
diffpy.pdffit2.redirect_stdout(savestdout)
46+
return fp.getvalue()
47+
return _capture

0 commit comments

Comments
 (0)