-
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
Fix failing Pytests (deprecation of raises(message=)
)
#666
Conversation
Replaced with pytest.fail(message), as described in https://docs.pytest.org/en/latest/deprecations.html#message-parameter-of-pytest-raises
message
argument to pytest.raises
, which we had unwisely muted along with all deprecation warnings in setup.cfg.raises(message=)
)
Codecov Report
@@ Coverage Diff @@
## master #666 +/- ##
==========================================
+ Coverage 94.07% 94.95% +0.88%
==========================================
Files 54 54
Lines 4656 4656
==========================================
+ Hits 4380 4421 +41
+ Misses 276 235 -41
Continue to review full report at Codecov.
|
Circleci failures related to miniconda docker image PATH issues: anaconda/docker-images#141 |
2cbb0ae
to
76e93bb
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.
Looks great to me! Thank you for fixing this.
[Also for future reference, the problems with how the message
keyword argument in pytest.raises
is used incorrectly are described in https://github.com/pytest-dev/pytest/issues/3974.]
@@ -39,7 +39,8 @@ def test_correct_shape_electric_field(self, h5_2d): | |||
assert h5_2d.electric_field.shape == (3, 51, 201) | |||
|
|||
def test_has_charge_density_with_units(self, h5_2d): | |||
assert h5_2d.charge_density.to(u.C / u.m**3) | |||
# this should simply pass without exception | |||
h5_2d.charge_density.to(u.C / u.m**3) |
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.
Good catch!
@@ -77,8 +77,6 @@ doctest_plus = enabled | |||
doctest_optionflags = NORMALIZE_WHITESPACE FLOAT_CMP ELLIPSIS | |||
# TODO we probably need to get rid of the following... | |||
filterwarnings = | |||
once::DeprecationWarning | |||
once::PendingDeprecationWarning |
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 wholeheartedly support this change, now that I think about it. ...as well as after doing an import this
.
Errors should never pass silently.
Unless explicitly silenced.
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.
Yeah, I'll try to tackle the removal of the other warning filters next. Come to think about it, we're probably exposing any potential users to a whole lot of Coupling or RelativityWarnings we have no idea about.
Thanks for the review @namurphy! |
This PR fixes currently failing tests caused by the final deprecation in Pytest 5.1 of the
message
argument topytest.raises
, which we had unwisely muted along with all deprecation warnings in setup.cfg.It also removes the same argument used in pytest.warns, which is slated for deprecation
in a future release.