Skip to content

Commit b18d485

Browse files
authored
Merge pull request #171 from alisnwu/tests-restruct
Reorganized test files to match src folder structure
2 parents b131d7f + 68841b9 commit b18d485

File tree

8 files changed

+31
-9
lines changed

8 files changed

+31
-9
lines changed

news/tests-restruct.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Added:**
2+
3+
* <news item>
4+
5+
**Changed:**
6+
7+
* \tests directory tree to match \src
8+
9+
**Deprecated:**
10+
11+
* <news item>
12+
13+
**Removed:**
14+
15+
* <news item>
16+
17+
**Fixed:**
18+
19+
* file paths of the test files according to new \tests directory tree
20+
21+
**Security:**
22+
23+
* <news item>

tests/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ def user_filesystem(tmp_path):
2222
@pytest.fixture
2323
def datafile():
2424
"""Fixture to dynamically load any test file."""
25+
base_path = Path(__file__).parent / "testdata" # Adjusted base path
2526

2627
def _load(filename):
27-
return "tests/testdata/" + filename
28+
return base_path / filename
2829

2930
return _load
File renamed without changes.

tests/test_serialization.py renamed to tests/diffpy/utils/parsers/test_serialization.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import os
1+
from pathlib import Path
22

33
import numpy
44
import pytest
@@ -7,26 +7,24 @@
77
from diffpy.utils.parsers.loaddata import loadData
88
from diffpy.utils.parsers.serialization import deserialize_data, serialize_data
99

10-
tests_dir = os.path.dirname(os.path.abspath(locals().get("__file__", "file.py")))
11-
1210

1311
def test_load_multiple(tmp_path, datafile):
1412
# Load test data
1513
targetjson = datafile("targetjson.json")
1614
generatedjson = tmp_path / "generated_serialization.json"
1715

18-
tlm_list = os.listdir(os.path.join(tests_dir, "testdata", "dbload"))
19-
tlm_list.sort()
16+
dbload_dir = datafile("dbload")
17+
tlm_list = sorted(dbload_dir.glob("*.gr"))
18+
2019
generated_data = None
21-
for hfname in tlm_list:
20+
for headerfile in tlm_list:
2221
# gather data using loadData
23-
headerfile = os.path.normpath(os.path.join(tests_dir, "testdata", "dbload", hfname))
2422
hdata = loadData(headerfile, headers=True)
2523
data_table = loadData(headerfile)
2624

2725
# check path extraction
2826
generated_data = serialize_data(headerfile, hdata, data_table, dt_colnames=["r", "gr"], show_path=True)
29-
assert headerfile == os.path.normpath(generated_data[hfname].pop("path"))
27+
assert headerfile == Path(generated_data[headerfile.name].pop("path"))
3028

3129
# rerun without path information and save to file
3230
generated_data = serialize_data(
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)