Skip to content

Commit b59afc6

Browse files
committed
TST: Check assertion not in callback
Otherwise we ignore the failures
1 parent c423658 commit b59afc6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/matplotlib/tests/test_backend_qt.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ def CustomHandler(signum, frame):
107107
('Key_Alt', ['ControlModifier'], 'ctrl+alt'),
108108
('Key_Aacute', ['ControlModifier', 'AltModifier', 'MetaModifier'],
109109
'ctrl+alt+super+\N{LATIN SMALL LETTER A WITH ACUTE}'),
110+
# We do not currently map the media keys, this may change in the
111+
# future. This means the callback will never fire
110112
('Key_Play', [], None),
111113
('Key_Backspace', [], 'backspace'),
112114
('Key_Backspace', ['ControlModifier'], 'ctrl+backspace'),
@@ -142,6 +144,7 @@ def test_correct_key(backend, qt_core, qt_key, qt_mods, answer):
142144
Assert sent and caught keys are the same.
143145
"""
144146
from matplotlib.backends.qt_compat import _enum, _to_int
147+
result = None
145148
qt_mod = _enum("QtCore.Qt.KeyboardModifier").NoModifier
146149
for mod in qt_mods:
147150
qt_mod |= getattr(_enum("QtCore.Qt.KeyboardModifier"), mod)
@@ -152,11 +155,13 @@ def key(self): return _to_int(getattr(_enum("QtCore.Qt.Key"), qt_key))
152155
def modifiers(self): return qt_mod
153156

154157
def on_key_press(event):
155-
assert event.key == answer
158+
global result
159+
result = event.key
156160

157161
qt_canvas = plt.figure().canvas
158162
qt_canvas.mpl_connect('key_press_event', on_key_press)
159163
qt_canvas.keyPressEvent(_Event())
164+
assert result == answer
160165

161166

162167
@pytest.mark.backend('QtAgg', skip_on_importerror=True)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy