-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TST: Fail on warning #22699
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
TST: Fail on warning #22699
Conversation
Fixing all the warnings is definitely great! About harcoding |
If it turns all warnings into errors, it might close #13962 as well. |
@rth thanks for the context, that's helpful. I think that elevating warnings to errors only on worker with the latest dependencies makes the most sense. I'll probably keep at this until things are passing, and then limit the elevation once things are passing.
Thanks for the link. It should close that. |
pandas/conftest.py
Outdated
@@ -31,6 +32,16 @@ def pytest_addoption(parser): | |||
help="Fail if a test is skipped for missing data file.") | |||
|
|||
|
|||
def pytest_collection_modifyitems(items): |
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 don't think we'll want this permanently. This is just to track down #22675 in case it happens on this branch.
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.
Do we need this as part of the ultimate change or no?
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'm tempted to leave it in master for a week or two to see if we catch any of the failures in action. I've made myself a reminder to remove it.
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.
sighhhhhhhhhhhhhhhhhhhhhhhhhhhh. we got one: https://travis-ci.org/pandas-dev/pandas/jobs/429657921#L2280, but that doesn't actually fail the right test, because the warning is in the file object's __del__
, just prints out to stderr rather than raising an exception (to fail the test).
I'm going to do some debugging on the branch.
I wasn't able to get the suggestion of
to work reliably. In my small test of
the panel warning was not elevated to an error, but the |
This reverts commit cf60217.
Those interested in the ResourceWarning failures may want to take a look at cfb5ae2. I tried to squash all the places we may have had unclosed files sitting around. If I had to guess, either cfb5ae2#diff-0d7b5a2c72b4dfc11d80afe159d45ff8R389 or cfb5ae2#diff-9d7323cc6b0cfa3f4482bc8d4268966dR213 is going to be the one that fixes it, but who knows. |
I think I've addressed all the inline comments Sorry to push on this relatively quickly, but I want to get our CI in a healthy state again. If possible, I'd like to merge this today. I currently have two followup issues for warnings that need some care
@jreback can you clarify our current policy on "allowed failures"? I don't recall why they're in the allowed-failures section. |
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.
@TomAugspurger awesome effort here. This was for sure a sore point. Some minor comments.
with tm.assert_prodcues_warning(FutureWarning): | ||
df.some_operation() | ||
|
||
We prefer this to the ``pytest.warns`` context manager because ours checks that the warning's |
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 may want to mention that we will actually fail if pytest.warns will fail the linter :>
(dtype.startswith("Int") or dtype.startswith("UInt"))): | ||
# Avoid DeprecationWarning from NumPy about np.dtype("Int64") | ||
# https://github.com/numpy/numpy/pull/7476 | ||
dtype = dtype.lower() |
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.
oh I didn't know numpy did this:
In [1]: np.dtype('Int64')
/Users/jreback/miniconda3/envs/pandas/bin/ipython:1: DeprecationWarning: Numeric-style type codes are deprecated and will result in an error in the future.
#!/Users/jreback/miniconda3/envs/pandas/bin/python
Out[1]: dtype('int64')
I guess so, thanks
@@ -758,7 +758,7 @@ def aggregate(self, func_or_funcs, *args, **kwargs): | |||
if isinstance(func_or_funcs, compat.string_types): | |||
return getattr(self, func_or_funcs)(*args, **kwargs) | |||
|
|||
if isinstance(func_or_funcs, collections.Iterable): | |||
if isinstance(func_or_funcs, compat.Iterable): |
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.
in theory we could add a lint rule to avoid using collection.Iterable
, and instead just use our compat
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 think we're close enough to py3-only that we'll be OK. Writing that regex would be a bit fiddly since we'd need to enumerate all the ABCs.
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.
true, certainly a follow up issue is ok
@@ -3490,6 +3490,7 @@ def _putmask_smart(v, m, n): | |||
|
|||
# we ignore ComplexWarning here | |||
with warnings.catch_warnings(record=True): | |||
warnings.simplefilter("ignore", np.ComplexWarning) |
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.
does the context manager restore all of the warnings filters after? (I guess that is the point?)
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, that's the idea. Ideally libraries shouldn't modify the global warnings registry without good cause.
@@ -175,23 +174,23 @@ def test_get_store(self): | |||
|
|||
class TestParser(object): | |||
|
|||
@pytest.mark.filterwarnings("ignore") | |||
def test_deprecation_access_func(self): |
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.
should these actually be tm.assert_produces_warning(FutureWarning)
?
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.
nvm I see your comment below
@@ -1134,19 +1175,22 @@ def test_ix_frame_align(self): | |||
df = df_orig.copy() | |||
|
|||
with catch_warnings(record=True): | |||
simplefilter("ignore", DeprecationWarning) |
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.
grr....we should just remove all of this .ix bizness
@@ -508,30 +507,30 @@ def test_frame_multi_key_function_list(): | |||
|
|||
|
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.
we could prob split the panel tests to a separate file (and just ignore warnings there), maybe make an issue
def epochs(request): | ||
return request.param | ||
@pytest.fixture(params=['timestamp', 'pydatetime', 'datetime64', 'str_1960']) | ||
def epochs(epoch_1960, request): |
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 doc-string
@@ -10,6 +10,9 @@ | |||
import pandas.util.testing as tm | |||
|
|||
|
|||
ignore_ix = pytest.mark.filterwarnings("ignore:\\n.ix:DeprecationWarning") |
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.
maybe move this to the top-level conftest and use it above (a number of files where catching all of the ix warnings)
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.
Hmm do you know how to use marks defined in the top-level conftest.py
? I'm not actually sure that's possible.
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 think you can just import it
@@ -388,52 +388,61 @@ def test_iloc_getitem_frame(self): | |||
|
|||
result = df.iloc[2] | |||
with catch_warnings(record=True): | |||
filterwarnings("ignore", "\\n.ix", DeprecationWarning) |
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.
use ignore_ix?
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.
That filters the warning for the entire test. I was trying to exactly match the tests previous intent, of only filtering within the catch_warnings
blocks.
so they are really there to get a probable green faster. I don't really have a problem moving them to required builds actually. |
Thanks. So I think it's best to treat numpy / dateutil dev as "allowed failures" but as soon as we see a failure we should open an issue that would block the next release (and maybe report upstream if it looks like an unintentional break). We might consider moving the doc build to azure. Apparently the workers more powerful than Travis. |
yep, that's the idea
certainly |
@TomAugspurger merge when you are ready |
👍 pushed some doc fixes. Will merge on green. |
Travis all passed. Merging. |
Sets our pytest config to fail on unhandled warnings.
Fixes a bunch of tests to not fail.
This still has a few TODOs.
Closes #16481
Closes #19677
Closes #13962
Closes #22020