-
Notifications
You must be signed in to change notification settings - Fork 262
TEST: Suppress expected warnings #949
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #949 +/- ##
==========================================
+ Coverage 91.84% 91.87% +0.02%
==========================================
Files 97 98 +1
Lines 12428 12451 +23
Branches 2191 2193 +2
==========================================
+ Hits 11415 11439 +24
Misses 678 678
+ Partials 335 334 -1
Continue to review full report at Codecov.
|
Down to a much more reasonable warnings list:
Filtering on-import warnings feels like more work than it's worth. Handling the NetCDF case would need its own PR. Looks like a couple warnings that actually need dealing with for upcoming Numpy... |
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.
Some notes for a potential reviewer...
@@ -205,7 +205,7 @@ def parse_ascconv(ascconv_str, str_delim='"'): | |||
attrs, content = ASCCONV_RE.match(ascconv_str).groups() | |||
attrs = OrderedDict((tuple(x.split('=')) for x in attrs.split())) | |||
# Normalize string start / end markers to something Python understands | |||
content = content.replace(str_delim, '"""') | |||
content = content.replace(str_delim, '"""').replace("\\", "\\\\") |
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.
This one seems like a reasonable fix, but it should get @matthew-brett's or @moloney's eyes to be sure. Previously the line:
tSequenceFileName = ""%SiemensSeq%\ep2d_diff""
Resulted in ast.parse()
emitting:
nibabel/nicom/tests/test_ascconv.py::test_ascconv_parse
<unknown>:2: DeprecationWarning: invalid escape sequence \e
@anibalsolon @djarecka @orduek @robbisg Could I trouble one of you for a review? |
3ca4ece
to
786cf99
Compare
@effigies - I can take a look, but I was never working on removing the warnings, so don't have experience with it. One question I have after quickly checking pytest website - have you tried |
No, I want warnings to show if they're valid, as that's one of the better ways to see upcoming deprecations in Python or numpy. But expected warnings that we produce shouldn't clutter the outputs. |
I can help, but as @djarecka, I never worked with suppressing warnings. ;) |
@effigies - ok, so you're concerned about your own warnings and you want to test them and remove from the output at the sam time. got it! |
@@ -345,11 +345,14 @@ def test_deprecated_fields(): | |||
|
|||
# mrparams is the only deprecated field at the moment | |||
# Accessing hdr_data is equivalent to accessing hdr, so double all checks | |||
assert_array_equal(hdr['mrparams'], 0) | |||
with pytest.deprecated_call(): |
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.
fyi. if you want to check specific warning, you can also use with pytest.deprecated_call(match="deprecated from version: 2.3")
assert issubclass(w[0].category, ExtensionWarning) | ||
assert "extension" in str(w[0].message) | ||
assert len(w) == 1 | ||
assert "extension" in str(w[0].message) |
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 could also use with pytest.warns(ExtensionWarning, match="extension")
@effigies -lgtm, i don't remember why we didn't move from |
I don't think I realized that pytest was breaking its behavior, and it seemed like an extra task to insert after getting tests working. Thanks for the suggestions. I think I'll go and look for all the warnings and improve them... |
Updated. Would appreciate another look through when you get a chance. |
Co-authored-by: Dorota Jarecka <djarecka@gmail.com>
All green. Good to merge? |
@effigies - I've just opened diff quickly, and wonder if there is any specific reason why you use |
Yes. When there's a standard library equivalent, I'm preferring that, on the grounds that one day we may need to migrate from pytest as we did from nose. The more things that are vanilla Python, the less work that should be. |
ok, i'm still hoping that we don't have to move from pytest anytime soon :-) |
Nose lasted 10 years, so if pytest does as well, we still have plenty of time. |
Thanks for reviewing! |
Tests are currently generating a huge number of warnings, which makes outputs less informative than they could be.
Will add subdirectories soon, but want to get CI going to make sure I'm not breaking things.