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

Conversation

alisnwu
Copy link

@alisnwu alisnwu commented Nov 12, 2024

closes #160

Screenshot 2024-11-12 at 11 23 46 AM

@sbillinge pytest passed, ready for review

Copy link

codecov bot commented Nov 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.17%. Comparing base (b131d7f) to head (68841b9).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #171      +/-   ##
==========================================
- Coverage   99.17%   99.17%   -0.01%     
==========================================
  Files           7        7              
  Lines         243      242       -1     
==========================================
- Hits          241      240       -1     
  Misses          2        2              
Files with missing lines Coverage Δ
tests/conftest.py 100.00% <100.00%> (ø)
tests/diffpy/utils/parsers/test_loaddata.py 97.77% <ø> (ø)
tests/diffpy/utils/parsers/test_serialization.py 100.00% <100.00%> (ø)
...ils/scattering_objects/test_diffraction_objects.py 100.00% <ø> (ø)
tests/diffpy/utils/test_resample.py 94.73% <ø> (ø)
tests/diffpy/utils/test_tools.py 100.00% <ø> (ø)
tests/diffpy/utils/test_version.py 100.00% <ø> (ø)

Copy link
Contributor

@sbillinge sbillinge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few inlines


def _load(filename):
return "tests/testdata/" + filename
return str(base_path / filename)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason you return a string and not the Path object?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to match the original return of strings but the Path object also works, will edit to just return the Path object

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This work is exactly what Path is designed for.


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 = os.path.dirname(datafile("dbload/e1.gr"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then do these two lines using pathlib and pathlib globing?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, will use pathlib for both parts

generated_data = None
for hfname in tlm_list:
# gather data using loadData
headerfile = os.path.normpath(os.path.join(tests_dir, "testdata", "dbload", hfname))
headerfile = os.path.join(dbload_dir, hfname)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here.

@alisnwu
Copy link
Author

alisnwu commented Nov 13, 2024

@sbillinge Ready for review
Screenshot 2024-11-12 at 9 28 11 PM

@sbillinge sbillinge merged commit b18d485 into diffpy:main Nov 13, 2024
5 checks passed
@sbillinge
Copy link
Contributor

Much nicer, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Organize test files according to src folder structure
2 participants