Skip to content

Reorganized test files to match src folder structure #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 13, 2024
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
23 changes: 23 additions & 0 deletions news/tests-restruct.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* <news item>

**Changed:**

* \tests directory tree to match \src

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* file paths of the test files according to new \tests directory tree

**Security:**

* <news item>
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ def user_filesystem(tmp_path):
@pytest.fixture
def datafile():
"""Fixture to dynamically load any test file."""
base_path = Path(__file__).parent / "testdata" # Adjusted base path

def _load(filename):
return "tests/testdata/" + filename
return base_path / filename

return _load
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os
from pathlib import Path

import numpy
import pytest
Expand All @@ -7,26 +7,24 @@
from diffpy.utils.parsers.loaddata import loadData
from diffpy.utils.parsers.serialization import deserialize_data, serialize_data

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


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

tlm_list = os.listdir(os.path.join(tests_dir, "testdata", "dbload"))
tlm_list.sort()
dbload_dir = datafile("dbload")
tlm_list = sorted(dbload_dir.glob("*.gr"))

generated_data = None
for hfname in tlm_list:
for headerfile in tlm_list:
# gather data using loadData
headerfile = os.path.normpath(os.path.join(tests_dir, "testdata", "dbload", hfname))
hdata = loadData(headerfile, headers=True)
data_table = loadData(headerfile)

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

# rerun without path information and save to file
generated_data = serialize_data(
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading