-
Notifications
You must be signed in to change notification settings - Fork 667
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
Add tests for exception raise in PSA (closes #4036) #4037
Conversation
xhgchen
commented
Feb 22, 2023
•
edited
Loading
edited
- Closes Add tests for get_num_atoms exception raise in PSA (per issue #597) #4036
- Towards Tests should make MDAnalysis raise exceptions #597
- Checks that get_num_atoms in PSAnalysis and Path raises a ValueError and displays "No path data"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello there first time contributor! Welcome to the MDAnalysis community! We ask that all contributors abide by our Code of Conduct and that first time contributors introduce themselves on the developer mailing list so we can get to know you. You can learn more about participating here. Please also add yourself to package/AUTHORS
as part of this PR.
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## develop #4037 +/- ##
===========================================
+ Coverage 93.54% 93.56% +0.02%
===========================================
Files 191 191
Lines 25065 25065
Branches 4042 4042
===========================================
+ Hits 23446 23452 +6
+ Misses 1099 1093 -6
Partials 520 520
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
e75a102
to
18d63d4
Compare
run Path.to_path()""" | ||
match_exp = "No path data" | ||
with pytest.raises(ValueError, match=match_exp): | ||
universe1 = mda.Universe(PSF, DCD) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are going to use these Universes
more than once probably best to make them a fixture
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! Thanks for the feedback! I also reorganized my tests to go under class TestPSAExceptions and added 2 new tests for psa.get_num_paths and psa.get_paths as I realized those functions needed similar testing. That should cover all the "no path data" type exceptions in the module.
class TestPSAExceptions(object): | ||
'''Tests for exceptions that should be raised | ||
or caught by code in the psa module.''' | ||
|
||
@pytest.fixture() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can probably collapse these tests into one test where you call each method sequentially, would save a bit of space.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, I was actually wondering whether that was appropriate too but I was hesitant as I read someone mention on Stack Overflow that they preferred testing them individually. I left the fixture there because I think it may be applicable for future tests, but please let me know if it would be better to remove it.
# Cases where user did not run PSAnalysis.generate_paths() | ||
with pytest.raises(ValueError, match=match_exp): | ||
psa.get_num_atoms() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a quick comment for last two cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For sure! I finished adding new comments and also tried to make the comments more clear. Changes should be final now, but please let me know if there is anything else that can be done. I messed up the commit history while trying to rebase and resolve conflicts but I managed to fix it with a hard reset. Definitely learned a lot while troubleshooting that!
Edit: Codecov is acting strangely with the checks; did something happen?
cbeffab
to
7c3de5b
Compare
@xhgchen the CI is being flaky, I will re-run it. |
7c3de5b
to
50fbe86
Compare
@hmacdope I pushed just now to resolve conflicts but did not make any other changes. Hopefully the checks run better this time! |
50fbe86
to
8d9a012
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @xhgchen looks great.
Would another @MDAnalysis/coredevs or @MDAnalysis/gsoc-mentors be able to take a quick look?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just as an FYI on this - non flake8 failure of the darker lint are fine, they should only be considered informative. |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Thank you all for taking the time to review this! I did check the darker lint failure multiple times but I left it alone after fixing the style issues in my first few commits as it did not seem to involve my code. If I was mistaken and there is anything specific I can fix, I would be happy to make those changes! |
Yeah style things optional. :) |
* Towards MDAnalysis#597 * Checks that get_num_atoms in PSAnalysis and Path raises a ValueError and displays "No path data"
* Make universe1 = mda.Universe(PSF, DCD) a fixture * Add similar tests to raise ValueErrors for get_num_paths and get_paths * Reorganize tests under class TestPSAExceptions
8d9a012
to
8b10e29
Compare
Just resolving a CHANGELOG conflict :) |
Can we merge the PR, @hmacdope ? |
yep all good! |