Skip to content

Commit 2396e90

Browse files
committed
TST: fix wx window closing test
Flush the wx canvas, not the base canvas that is installed on close.
1 parent eab4a89 commit 2396e90

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/matplotlib/tests/test_backends_interactive.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,13 @@ def _test_thread_impl():
288288
future = ThreadPoolExecutor().submit(fig.canvas.draw)
289289
plt.pause(0.5) # flush_events fails here on at least Tkagg (bpo-41176)
290290
future.result() # Joins the thread; rethrows any exception.
291+
# stash the current canvas as closing the figure will reset the canvas on
292+
# the figure
293+
canvas = fig.canvas
291294
plt.close() # backend is responsible for flushing any events here
292295
if plt.rcParams["backend"].lower().startswith("wx"):
293296
# TODO: debug why WX needs this only on py >= 3.8
294-
fig.canvas.flush_events()
297+
canvas.flush_events()
295298

296299

297300
_thread_safe_backends = _get_testable_interactive_backends()

0 commit comments

Comments
 (0)