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
Elevate warnings to errors in the test suite #6094
Conversation
6367375
to
f9c1515
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 @graingert
@@ -194,7 +194,7 @@ def close(self, timeout=None): | |||
return self.sync(self._close, callback_timeout=timeout) | |||
|
|||
def __del__(self): | |||
if self.status != Status.closed: | |||
if getattr(self, "status", Status.closed) != Status.closed: |
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.
When would a Cluster
instance not have a status
attribute?
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.
attributes aren't guaranteed to exist in def __del__
|
||
|
||
@pytest.mark.avoid_ci | ||
def test_old_ssh_with_local_dir(loop): | ||
with pytest.warns(Warning): |
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.
It appears we're just dropping the pytest.warns
ctx manager here. Was this test just failing before, but went unnoticed due to the pytest.mark.avoid_ci
marker?
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.
introduced here, it doesn't warn anymore (or at least when I run the test on my machine)!
@@ -264,12 +265,14 @@ async def test_assert_no_warning_no_overload(c, s, a): | |||
class Dummy(WorkerPlugin): | |||
pass | |||
|
|||
with pytest.warns(None): | |||
with warnings.catch_warnings(record=True) as record: |
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.
Nice, thanks for cleaning this pytest
deprecation up
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.
technically with warnings.catch_warnings(record=True) as record: .... assert not record
isn't needed with filterwarnings=error
because warnings will throw errors and fail the test. But I left it in in case filterwarnings
config is ever removed
for i in range(10): | ||
future = c.submit(lambda x, y: x, data, i) | ||
|
||
assert len(record) < 2 |
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.
IIUC it looks like we're dropping this check
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've now restored this as assert not record
f9c1515
to
5c20cda
Compare
ffee354
to
c576960
Compare
befe6e1
to
d6e7f12
Compare
pytest.warns automatically configures warnings.simplefilter("always")
d6e7f12
to
8f11999
Compare
@jrbourbeau do you have time to continue reviewing this? |
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 @graingert -- the changes here look good to me, thank you for working on this. As I mentioned offline, I'm curious to see how often new warnings pop up (now as test failures). But this certainly has value, so let's give it a try
Also, it's nice to see a fully green build ✅
pre-commit run --all-files