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

Skip to content

Commit 4ac125e

Browse files
authored
Merge pull request #10215 from anntzer/more-interactive-tests
Test timers and (a bit) key_press_event for interactive backends.
2 parents dec87a3 + 3b555d5 commit 4ac125e

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

.travis.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ env:
4848
- secure: RgJI7BBL8aX5FTOQe7xiXqWHMxWokd6GNUWp1NUV2mRLXPb9dI0RXqZt3UJwKTAzf1z/OtlHDmEkBoTVK81E9iUxK5npwyyjhJ8yTJmwfQtQF2n51Q1Ww9p+XSLORrOzZc7kAo6Kw6FIXN1pfctgYq2bQkrwJPRx/oPR8f6hcbY=
4949
- secure: E7OCdqhZ+PlwJcn+Hd6ns9TDJgEUXiUNEI0wu7xjxB2vBRRIKtZMbuaZjd+iKDqCKuVOJKu0ClBUYxmgmpLicTwi34CfTUYt6D4uhrU+8hBBOn1iiK51cl/aBvlUUrqaRLVhukNEBGZcyqAjXSA/Qsnp2iELEmAfOUa92ZYo1sk=
5050
- secure: "dfjNqGKzQG5bu3FnDNwLG8H/C4QoieFo4PfFmZPdM2RY7WIzukwKFNT6kiDfOrpwt+2bR7FhzjOGlDECGtlGOtYPN8XuXGjhcP4a4IfakdbDfF+D3NPIpf5VlE6776k0VpvcZBTMYJKNFIMc7QPkOwjvNJ2aXyfe3hBuGlKJzQU="
51+
# Variables controlling Python dependencies.
5152
- CYCLER=cycler
5253
- DATEUTIL=python-dateutil
5354
- NOSE=
@@ -58,12 +59,15 @@ env:
5859
- PYTEST_COV=pytest-cov
5960
- PYTEST_PEP8=
6061
- SPHINX=sphinx
61-
- OPENBLAS_NUM_THREADS=1
62+
# Variables controlling the test run.
63+
- DELETE_FONT_CACHE=
64+
- NO_AT_BRIDGE=1 # Necessary for GTK3 interactive test.
6265
- NPROC=2
63-
- RUN_PEP8=
66+
- OPENBLAS_NUM_THREADS=1
67+
- PYTHONFAULTHANDLER=1
6468
- PYTEST_ARGS="-rawR --maxfail=50 --timeout=300 --durations=25 --cov-report= --cov=lib -n $NPROC"
6569
- PYTHON_ARGS=
66-
- DELETE_FONT_CACHE=
70+
- RUN_PEP8=
6771

6872
matrix:
6973
include:

lib/matplotlib/backends/backend_wx.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -667,9 +667,6 @@ def __init__(self, parent, id, figure):
667667
def macros(self):
668668
return {}
669669

670-
def Destroy(self, *args, **kwargs):
671-
wx.Panel.Destroy(self, *args, **kwargs)
672-
673670
def Copy_to_Clipboard(self, event=None):
674671
"copy bitmap of canvas to system clipboard"
675672
bmp_obj = wx.BitmapDataObject()

lib/matplotlib/tests/test_backends_interactive.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ def _get_testable_interactive_backends():
3434
return backends
3535

3636

37+
# 1. Using a timer not only allows testing of timers (on other backends), but
38+
# is also necessary on gtk3 and wx, where a direct call to
39+
# key_press_event("q") from draw_event causes breakage due to the canvas
40+
# widget being deleted too early.
41+
# 2. On gtk3, we cannot even test the timer setup (on Travis, which uses pgi)
42+
# due to https://github.com/pygobject/pgi/issues/45. So we just cleanly
43+
# exit from the draw_event.
3744
_test_script = """\
3845
import sys
3946
from matplotlib import pyplot as plt, rcParams
@@ -44,8 +51,16 @@ def _get_testable_interactive_backends():
4451
4552
fig = plt.figure()
4653
ax = fig.add_subplot(111)
47-
ax.plot([1, 2], [2, 3])
48-
fig.canvas.mpl_connect("draw_event", lambda event: sys.exit())
54+
ax.plot([0, 1], [2, 3])
55+
56+
if rcParams["backend"].startswith("GTK3"):
57+
fig.canvas.mpl_connect("draw_event", lambda event: sys.exit(0))
58+
else:
59+
timer = fig.canvas.new_timer(1)
60+
timer.add_callback(fig.canvas.key_press_event, "q")
61+
# Trigger quitting upon draw.
62+
fig.canvas.mpl_connect("draw_event", lambda event: timer.start())
63+
4964
plt.show()
5065
"""
5166
_test_timeout = 10 # Empirically, 1s is not enough on Travis.

0 commit comments

Comments
 (0)