Skip to content

Commit b7f9ff2

Browse files
Alison WuAlison Wu
authored andcommitted
fixed file paths in test files for the changed tests structure
1 parent ada9157 commit b7f9ff2

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

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 str(base_path / filename)
2829

2930
return _load

tests/diffpy/utils/parsers/test_serialization.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,19 @@
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 = os.path.dirname(datafile("dbload/e1.gr"))
17+
tlm_list = sorted(os.listdir(dbload_dir))
18+
2019
generated_data = None
2120
for hfname in tlm_list:
2221
# gather data using loadData
23-
headerfile = os.path.normpath(os.path.join(tests_dir, "testdata", "dbload", hfname))
22+
headerfile = os.path.join(dbload_dir, hfname)
2423
hdata = loadData(headerfile, headers=True)
2524
data_table = loadData(headerfile)
2625

0 commit comments

Comments
 (0)