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

Matplotlib 3.8 test warning #2277

Merged
merged 2 commits into from
Oct 20, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
use callback
  • Loading branch information
lgolston committed Oct 19, 2023
commit 696031bcb30deb4373801f4b12a7525762d504db
2 changes: 1 addition & 1 deletion lib/cartopy/tests/mpl/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ def mpl_test_cleanup(request):
with ExitStack() as stack:
# At exit, close all open figures and switch backend back to original.
stack.callback(plt.switch_backend, plt.get_backend())
stack.callback(plt.close, 'all')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it matter whether we close all before or after the switch backend?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if line 17 and 18 are swapped the warning is still given. Since the stack goes in reverse order, I think the flow is that on exit the plot is closed, then backend is switched to original.


# Run each test in a context manager so that state does not leak out
plt.switch_backend('Agg')
stack.enter_context(plt.rc_context())
yield
plt.close('all')


def pytest_itemcollected(item):
Expand Down