-
Notifications
You must be signed in to change notification settings - Fork 339
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
Move pytest helpers to subdirectory of utils #674
Move pytest helpers to subdirectory of utils #674
Conversation
Hello @namurphy! Thanks for updating your pull request.
Comment last updated at 2019-09-06 00:00:51 UTC |
2dfea2e
to
d103a51
Compare
Codecov Report
@@ Coverage Diff @@
## master #674 +/- ##
==========================================
+ Coverage 94.95% 95.03% +0.07%
==========================================
Files 55 58 +3
Lines 4661 4674 +13
==========================================
+ Hits 4426 4442 +16
+ Misses 235 232 -3
Continue to review full report at Codecov.
|
d103a51
to
a2740fc
Compare
Our pytest helpers functionality has been in a single file in plasmapy.utils, which means that the functionality in there is jumbled together with a bunch of other unrelated things. Putting it in its own subdirectory will help with the organization. I also split the existing functionality in pytest. I updated the namespaces for run_test, etc. in a bunch of test files throughout the package. I also made a few non-consequential changes in the test files that I noticed, mostly removing unused import statements. I am planning on doing more refactoring to the pytest helpers functionality, which will enable me to do some more refactoring of tests. The API for utils.pytest_helpers should be considered unstable at the moment.
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.
Looks Mostly Good To Me! 👍
One point I should probably be raising somewhere else, though: I saw pytest_helpers messing up when plugged into the parallel testing of pytest_xdist
somewhere along the last few of my PRs (apologies for not bringing that up sooner) - as this code base grows, we're going to be finding more edge cases... I guess my point is that we should really make sure we aren't reinventing Pytest's own functionalities in here and stick with the "canonical" solutions to problems. I think I remember thinking "this would have been fine with a fixture" in a bunch of places around test_atomic.
I'm deeply sorry for being vague and unhelpful right now >_<
# keyword_string = ", " + str(kwargs).strip(r"}{'").replace("'", "").replace(":", " =") | ||
# else: | ||
# keyword_string = "" | ||
# return f"Particle({repr(arg)}{keyword_string})" |
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.
Dump the commented out code, maybe?
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.
Oops! I forgot about this. Thanks!
@@ -9,7 +9,7 @@ | |||
_case_insensitive_aliases, | |||
_case_sensitive_aliases, | |||
_parse_and_check_atomic_input, | |||
_call_string, | |||
_particle_call_string, # duplicate with utils.pytest_helpers.error_messages.call_string? |
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.
What's that about?
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.
I made a more general plasampy.utils.pytest_helpers.call_string
function which creates a string that replicates the call from a supplied callable, args, and kwargs to help with error messages, so this private function for a specific case is no longer necessary. I might as well go back and finish this change that I started but did not finish.
@@ -36,6 +36,4 @@ | |||
|
|||
from .relativity import Lorentz_factor | |||
|
|||
from plasmapy import transport | |||
|
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.
... wow, I have no idea why this was here. I'm surprised things didn't break by removing this!
Huh, strange! If you have an idea for a failing test, that would be great. Otherwise I can try to play around with it to see what problems I might run into.
My thought for the time being is that I want something like >>> run_test(callable_object, args_list, kwargs_dict, expected_outcome) that works if |
Our pytest helpers functionality has been in a single file in plasmapy.utils, which means that the functionality in there is jumbled together with a bunch of other unrelated things. Putting it in its own subdirectory will help with the organization. I also split the existing functionality in pytest.
I updated the namespaces for run_test, etc. in a bunch of test files throughout the package. I also made a few non-consequential changes in the test files that I noticed, mostly removing unused import statements.
I am planning on doing more refactoring to the pytest helpers functionality, which will enable me to do some more refactoring of tests (discussed in comments in #605). The API for utils.pytest_helpers should be considered unstable at the moment.