From 480be80a41fc20c27173e31d6cdee8da63bbe659 Mon Sep 17 00:00:00 2001 From: Alexander Goscinski Date: Mon, 25 Dec 2023 18:47:34 +0100 Subject: [PATCH] fix jupyter lab nb of matplotlib canvases Sometimes in jupyter lab 5 canvases exist, one is not displayable and can be ignored. In this fix we filter out all canvases that are not displayable. --- tests/test_widgets.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_widgets.py b/tests/test_widgets.py index a2acd34..eb36902 100644 --- a/tests/test_widgets.py +++ b/tests/test_widgets.py @@ -576,6 +576,11 @@ def test_cue_figure( # in the notebook an image of the python logo is shown as first canvas, so # we remove it matplotlib_canvases = matplotlib_canvases[1:] + elif JUPYTER_TYPE == "lab": + # sometimes another canvas is shown that we filter out + matplotlib_canvases = [ + canvas for canvas in matplotlib_canvases if canvas.is_displayed() + ] assert ( len(matplotlib_canvases) >= nb_expected_canvases