8000 Test timers and (a bit) key_press_event for interactive backends. · matplotlib/matplotlib@3b555d5 · GitHub
[go: up one dir, main page]

Skip to content

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

8000
Appearance settings

Commit 3b555d5

Browse files
committed
Test timers and (a bit) key_press_event for interactive backends.
1 parent 6169fa2 commit 3b555d5

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
@@ -46,6 +46,7 @@ env:
4646
- secure: RgJI7BBL8aX5FTOQe7xiXqWHMxWokd6GNUWp1NUV2mRLXPb9dI0RXqZt3UJwKTAzf1z/OtlHDmEkBoTVK81E9iUxK5npwyyjhJ8yTJmwfQtQF2n51Q1Ww9p+XSLORrOzZc7kAo6Kw6FIXN1pfctgYq2bQkrwJPRx/oPR8f6hcbY=
4747
- secure: E7OCdqhZ+PlwJcn+Hd6ns9TDJgEUXiUNEI0wu7xjxB2vBRRIKtZMbuaZjd+iKDqCKuVOJKu0ClBUYxmgmpLicTwi34CfTUYt6D4uhrU+8hBBOn1iiK51cl/aBvlUUrqaRLVhukNEBGZcyqAjXSA/Qsnp2iELEmAfOUa92ZYo1sk=
4848
- secure: "dfjNqGKzQG5bu3FnDNwLG8H/C4QoieFo4PfFmZPdM2RY7WIzukwKFNT6kiDfOrpwt+2bR7FhzjOGlDECGtlGOtYPN8XuXGjhcP4a4IfakdbDfF+D3NPIpf5VlE6776k0VpvcZBTMYJKNFIMc7QPkOwjvNJ2aXyfe3hBuGlKJzQU="
49+
# Variables controlling Python dependencies.
4950
- CYCLER=cycler
5051
- DATEUTIL=python-dateutil
5152
- NOSE=
@@ -56,12 +57,15 @@ env:
5657
- PYTEST_COV=pytest-cov
5758
- PYTEST_PEP8=
5859
- SPHINX=sphinx
59-
- OPENBLAS_NUM_THREADS=1
60+
# Variables controlling the test run.
61+
- DELETE_FONT_CACHE=
62+
- NO_AT_BRIDGE=1 # Necessary for GTK3 interactive test.
6063
- NPROC=2
61-
- RUN_PEP8=
64+
- OPENBLAS_NUM_THREADS=1
65+
- PYTHONFAULTHANDLER=1
6266
- PYTEST_ARGS="-rawR --maxfail=50 --timeout=300 --durations=25 --cov-report= --cov=lib -n $NPROC"
6367
- PYTHON_ARGS=
64-
- DELETE_FONT_CACHE=
68+
- RUN_PEP8=
6569

6670
matrix:
6771
include:

lib/matplotlib/backends/backend_wx.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -663,9 +663,6 @@ def do_nothing(*args, **kwargs):
663663

664664
self.macros = {} # dict from wx id to seq of macros
665665

666-
def Destroy(self, *args, **kwargs):
667-
wx.Panel.Destroy(self, *args, **kwargs)
668-
669666
def Copy_to_Clipboard(self, event=None):
670667
"copy bitmap of canvas to system clipboard"
671668
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)
0