Skip to content

Commit b19c917

Browse files
authored
Merge pull request diffpy#79 from bobleesj/tests-dir
Move tests folder to top level for further refactoring
2 parents 2d439b6 + f9cae2c commit b19c917

24 files changed

+305
-388
lines changed

.github/workflows/codecov.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
conda install --file requirements/test.txt
4141
conda install --file requirements/build.txt
4242
python -m pip install -r requirements/pip.txt
43-
python -m pip install -e . --no-deps
43+
python -m pip install . --no-deps
4444
4545
- name: Validate diffpy.pdffit2
4646
run: |

.github/workflows/docs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
conda install --file requirements/run.txt
3737
conda install --file requirements/docs.txt
3838
python -m pip install -r requirements/pip.txt
39-
python -m pip install -e . --no-deps
39+
python -m pip install . --no-deps
4040
4141
- name: build documents
4242
run: make -C doc html

.github/workflows/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
conda install --file requirements/test.txt
3838
conda install --file requirements/build.txt
3939
python -m pip install -r requirements/pip.txt
40-
python -m pip install -e . --no-deps
40+
python -m pip install . --no-deps
4141
4242
- name: Validate diffpy.pdffit2
4343
run: python -m pytest

.github/workflows/matrix.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
conda install --file requirements/test.txt
4343
conda install --file requirements/build.txt
4444
python -m pip install -r requirements/pip.txt
45-
python -m pip install -e . --no-deps
45+
python -m pip install . --no-deps
4646
4747
- name: Validate diffpy.pdffit2
4848
run: python -m pytest

conda-recipe/run_test.py

-5
This file was deleted.

pytest.ini

-2
This file was deleted.

src/diffpy/pdffit2/tests/__init__.py

-83
This file was deleted.

src/diffpy/pdffit2/tests/conftest.py

-19
This file was deleted.

src/diffpy/pdffit2/tests/debug.py

-35
This file was deleted.

src/diffpy/pdffit2/tests/pdffit2testutils.py

-53
This file was deleted.

src/diffpy/pdffit2/tests/run.py

-56
This file was deleted.

tests/conftest.py

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import json
2+
from pathlib import Path
3+
4+
import pytest
5+
import six
6+
7+
import diffpy.pdffit2
8+
import diffpy.pdffit2.output # assuming this is the correct import path
9+
10+
11+
@pytest.fixture
12+
def user_filesystem(tmp_path):
13+
base_dir = Path(tmp_path)
14+
home_dir = base_dir / "home_dir"
15+
home_dir.mkdir(parents=True, exist_ok=True)
16+
cwd_dir = base_dir / "cwd_dir"
17+
cwd_dir.mkdir(parents=True, exist_ok=True)
18+
19+
home_config_data = {"username": "home_username", "email": "[email protected]"}
20+
with open(home_dir / "diffpyconfig.json", "w") as f:
21+
json.dump(home_config_data, f)
22+
23+
yield tmp_path
24+
25+
26+
@pytest.fixture
27+
def datafile():
28+
"""Fixture to dynamically load any test file."""
29+
30+
def _load(filename):
31+
return "tests/testdata/" + filename
32+
33+
return _load
34+
35+
36+
@pytest.fixture
37+
def capture_output():
38+
"""Capture output from pdffit2 engine produced in function call."""
39+
40+
def _capture(f, *args, **kwargs):
41+
savestdout = diffpy.pdffit2.output.stdout
42+
fp = six.StringIO()
43+
diffpy.pdffit2.redirect_stdout(fp)
44+
try:
45+
f(*args, **kwargs)
46+
finally:
47+
diffpy.pdffit2.redirect_stdout(savestdout)
48+
return fp.getvalue()
49+
50+
return _capture

0 commit comments

Comments
 (0)