Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9bc82fb

Browse files
tighten and comment test_never_update
1 parent 880c6c5 commit 9bc82fb

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

lib/matplotlib/tests/test_backends_interactive.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,30 @@ def test_webagg():
197197

198198

199199
@pytest.mark.backend('TkAgg', skip_on_importerror=True)
200-
def test_never_update(monkeypatch):
200+
def test_never_update(monkeypatch, capsys):
201201
import tkinter
202202
monkeypatch.delattr(tkinter.Misc, 'update')
203203
monkeypatch.delattr(tkinter.Misc, 'update_idletasks')
204204

205205
import matplotlib.pyplot as plt
206-
plt.plot([1, 2, 3], [1, 3, 5])
206+
fig = plt.figure()
207207
plt.show(block=False)
208-
fig = plt.gcf()
208+
209+
# regression test on FigureCanvasTkAgg
210+
plt.draw()
211+
# regression test on NavigationToolbar2Tk
209212
fig.canvas.toolbar.configure_subplots()
210-
plt.pause(1e-9)
213+
214+
# check for update() or update_idletasks() in the event queue
215+
# functionally equivalent to tkinter.Misc.update
216+
# must pause >= 1 ms to process tcl idle events plus
217+
# extra time to avoid flaky tests on slow systems
218+
plt.pause(0.1)
219+
220+
# regression test on FigureCanvasTk filter_destroy callback
221+
plt.close(fig)
222+
223+
# test framework doesn't see tkinter callback exceptions normally
224+
# see tkinter.Misc.report_callback_exception
225+
assert "Exception in Tkinter callback" not in capsys.readouterr().err
226+

0 commit comments

Comments
 (0)