From ecd52dd95a593f90a03e6948dbcba9b787f1bf1d Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Wed, 18 Sep 2024 21:55:16 -0400 Subject: [PATCH] TST: Fix minor issues in interactive backend test - Close the figure immediately, to avoid the deprecation warning about automatically closing figure when changing backends. This test doesn't intend to test the warning, just the change behaviour itself. - Enable the post-`show()` result check everywhere. The comment implies it should only be skipped on `(macOS and Qt5)`, but the condition is actually only enabled on `macOS and (not Qt5)`. --- lib/matplotlib/tests/test_backends_interactive.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/matplotlib/tests/test_backends_interactive.py b/lib/matplotlib/tests/test_backends_interactive.py index 2c6b61a48438..730d950ee5cd 100644 --- a/lib/matplotlib/tests/test_backends_interactive.py +++ b/lib/matplotlib/tests/test_backends_interactive.py @@ -166,7 +166,8 @@ def _test_interactive_impl(): if backend.endswith("agg") and not backend.startswith(("gtk", "web")): # Force interactive framework setup. - plt.figure() + fig = plt.figure() + plt.close(fig) # Check that we cannot switch to a backend using another interactive # framework, but can switch to a backend using cairo instead of agg, @@ -224,10 +225,7 @@ def check_alt_backend(alt_backend): result_after = io.BytesIO() fig.savefig(result_after, format='png') - if not backend.startswith('qt5') and sys.platform == 'darwin': - # FIXME: This should be enabled everywhere once Qt5 is fixed on macOS - # to not resize incorrectly. - assert result.getvalue() == result_after.getvalue() + assert result.getvalue() == result_after.getvalue() @pytest.mark.parametrize("env", _get_testable_interactive_backends()) @@ -444,8 +442,7 @@ def qt5_and_qt6_pairs(): for qt5 in qt5_bindings: for qt6 in qt6_bindings: - for pair in ([qt5, qt6], [qt6, qt5]): - yield pair + yield from ([qt5, qt6], [qt6, qt5]) @pytest.mark.parametrize('host, mpl', [*qt5_and_qt6_pairs()])