Skip to content
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

Fixes for pytest-8.0.0 compatibility #8686

Merged
merged 3 commits into from
Jan 31, 2024
Merged

Fixes for pytest-8.0.0 compatibility #8686

merged 3 commits into from
Jan 31, 2024

Conversation

mgorny
Copy link
Contributor

@mgorny mgorny commented Jan 31, 2024

Two fixes for compatibility with pytest 8.0.0:

  1. Removed pytest.warns() inside pytest.raises() where no warnings are actually raised.
  2. Cleared recorded warnings after pytest.warns() invocation where the function expected all warnings to be captured.

Explained in detail in commit messages.

Remove two incorrect `pytest.warns()` assertions to fix test failures
with pytest-8.0.0.  Prior to this version, an exception raised would
cause `pytest.warns()` to be ignored.  This way fixed in 8.0.0, and now
warnings must actually be emitted prior to the exception.

In `test_drop_index_labels()`, the exception is raised at the very
beginning of the function, prior to the deprecation warning.

In `test_rename_multiindex()`, the warning is not emitted at all (it is
not applicable to the call in question).
Clear the warnings recorded during the `pytest.warns()` use
in `test_groupby_dims_property`, to fix test failures with pytest-8.0.0.
Prior to this version, `pytest.warns()` invocation used to capture all
warnings.  Now it only captures the warnings that match the arguments,
and the remaining warnings are re-emitted and therefore caught by
`recwarn` fixture.  To provide compatibility with both versions of
pytest, clear the recorded warnings immediately after `pytest.warns()`.

Fixes pydata#8681
Copy link

welcome bot commented Jan 31, 2024

Thank you for opening this pull request! It may take us a few days to respond here, so thank you for being patient.
If you have questions, some answers may be found in our contributing guidelines.

This reverts commit b0b5b2f.
The tests should be fixed now.
@dcherian
Copy link
Contributor

Great first PR. Thanks @mgorny !

@dcherian dcherian merged commit ca10531 into pydata:main Jan 31, 2024
29 checks passed
Copy link

welcome bot commented Jan 31, 2024

Congratulations on completing your first pull request! Welcome to Xarray! We are proud of you, and hope to see you again! celebration gif

@mgorny
Copy link
Contributor Author

mgorny commented Jan 31, 2024

Thanks!

@mgorny mgorny deleted the pytest8 branch January 31, 2024 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CI Failures Associated with Pytest v8.0.0 Release
2 participants