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

Skip to content

Commit 286d0d4

Browse files
authored
Merge pull request #21148 from meeseeksmachine/auto-backport-of-pr-21142-on-v3.5.x
Backport PR #21142 on branch v3.5.x (Mac qt ctrl)
2 parents 87231d8 + 871a1f2 commit 286d0d4

File tree

2 files changed

+57
-42
lines changed

2 files changed

+57
-42
lines changed

.github/workflows/tests.yml

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -168,37 +168,38 @@ jobs:
168168
# (sometimes, the install appears to be successful but shared
169169
# libraries cannot be loaded at runtime, so an actual import is a
170170
# better check).
171-
if [[ "${{ runner.os }}" != 'macOS' ]]; then
172-
# PyGObject, pycairo, and cariocffi do not install on OSX 10.12.
173-
python -m pip install --upgrade pycairo 'cairocffi>=0.8' PyGObject &&
174-
python -c 'import gi; gi.require_version("Gtk", "3.0"); from gi.repository import Gtk' &&
175-
echo 'PyGObject is available' ||
176-
echo 'PyGObject is not available'
171+
# PyGObject, pycairo, and cariocffi do not install on OSX 10.12.
172+
python -m pip install --upgrade pycairo 'cairocffi>=0.8' PyGObject &&
173+
python -c 'import gi; gi.require_version("Gtk", "3.0"); from gi.repository import Gtk' &&
174+
echo 'PyGObject is available' ||
175+
echo 'PyGObject is not available'
177176
178-
# There are no functioning wheels available for OSX 10.12 (as of
179-
# Sept 2020) for either pyqt5 (there are only wheels for 10.13+) or
180-
# pyside2 (the latest version (5.13.2) with 10.12 wheels has a
181-
# fatal to us bug, it was fixed in 5.14.0 which has 10.13 wheels)
182-
python -mpip install --upgrade pyqt5${{ matrix.pyqt5-ver }} &&
183-
python -c 'import PyQt5.QtCore' &&
184-
echo 'PyQt5 is available' ||
185-
echo 'PyQt5 is not available'
177+
# There are no functioning wheels available for OSX 10.12 (as of
178+
# Sept 2020) for either pyqt5 (there are only wheels for 10.13+) or
179+
# pyside2 (the latest version (5.13.2) with 10.12 wheels has a
180+
# fatal to us bug, it was fixed in 5.14.0 which has 10.13 wheels)
181+
python -mpip install --upgrade pyqt5${{ matrix.pyqt5-ver }} &&
182+
python -c 'import PyQt5.QtCore' &&
183+
echo 'PyQt5 is available' ||
184+
echo 'PyQt5 is not available'
185+
if [[ "${{ runner.os }}" != 'macOS' ]]; then
186186
python -mpip install --upgrade pyside2 &&
187187
python -c 'import PySide2.QtCore' &&
188188
echo 'PySide2 is available' ||
189189
echo 'PySide2 is not available'
190-
# Qt6 crashes on Github's ubuntu 18.04 runner.
191-
if [[ "${{ matrix.os }}" = ubuntu-20.04 ]]; then
192-
python -mpip install --upgrade pyqt6 &&
193-
python -c 'import PyQt6.QtCore' &&
194-
echo 'PyQt6 is available' ||
195-
echo 'PyQt6 is not available'
196-
python -mpip install --upgrade pyside6 &&
197-
python -c 'import PySide6.QtCore' &&
198-
echo 'PySide6 is available' ||
199-
echo 'PySide6 is not available'
200-
fi
201190
fi
191+
# Qt6 crashes on Github's ubuntu 18.04 runner.
192+
if [[ "${{ matrix.os }}" = ubuntu-20.04 ]]; then
193+
python -mpip install --upgrade pyqt6 &&
194+
python -c 'import PyQt6.QtCore' &&
195+
echo 'PyQt6 is available' ||
196+
echo 'PyQt6 is not available'
197+
python -mpip install --upgrade pyside6 &&
198+
python -c 'import PySide6.QtCore' &&
199+
echo 'PySide6 is available' ||
200+
echo 'PySide6 is not available'
201+
fi
202+
202203
python -mpip install --upgrade \
203204
-f "https://extras.wxpython.org/wxPython4/extras/linux/gtk3/${{ matrix.os }}" \
204205
wxPython &&

lib/matplotlib/tests/test_backend_qt.py

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ def test_other_signal_before_sigint(qt_core, platform_simulate_ctrl_c,
9393
def custom_sigpipe_handler(signum, frame):
9494
nonlocal sigcld_caught
9595
sigcld_caught = True
96-
signal.signal(signal.SIGCLD, custom_sigpipe_handler)
96+
signal.signal(signal.SIGCHLD, custom_sigpipe_handler)
9797

9898
def fire_other_signal():
99-
os.kill(os.getpid(), signal.SIGCLD)
99+
os.kill(os.getpid(), signal.SIGCHLD)
100100

101101
def fire_sigint():
102102
platform_simulate_ctrl_c()
@@ -166,24 +166,33 @@ def custom_handler(signum, frame):
166166

167167

168168
@pytest.mark.parametrize(
169-
'qt_key, qt_mods, answer',
169+
"qt_key, qt_mods, answer",
170170
[
171-
('Key_A', ['ShiftModifier'], 'A'),
172-
('Key_A', [], 'a'),
173-
('Key_A', ['ControlModifier'], 'ctrl+a'),
174-
('Key_Aacute', ['ShiftModifier'],
175-
'\N{LATIN CAPITAL LETTER A WITH ACUTE}'),
176-
('Key_Aacute', [],
177-
'\N{LATIN SMALL LETTER A WITH ACUTE}'),
178-
('Key_Control', ['AltModifier'], 'alt+control'),
179-
('Key_Alt', ['ControlModifier'], 'ctrl+alt'),
180-
('Key_Aacute', ['ControlModifier', 'AltModifier', 'MetaModifier'],
181-
'ctrl+alt+meta+\N{LATIN SMALL LETTER A WITH ACUTE}'),
171+
("Key_A", ["ShiftModifier"], "A"),
172+
("Key_A", [], "a"),
173+
("Key_A", ["ControlModifier"], ("ctrl+a")),
174+
(
175+
"Key_Aacute",
176+
["ShiftModifier"],
177+
"\N{LATIN CAPITAL LETTER A WITH ACUTE}",
178+
),
179+
("Key_Aacute", [], "\N{LATIN SMALL LETTER A WITH ACUTE}"),
180+
("Key_Control", ["AltModifier"], ("alt+control")),
181+
("Key_Alt", ["ControlModifier"], "ctrl+alt"),
182+
(
183+
"Key_Aacute",
184+
["ControlModifier", "AltModifier", "MetaModifier"],
185+
("ctrl+alt+meta+\N{LATIN SMALL LETTER A WITH ACUTE}"),
186+
),
182187
# We do not currently map the media keys, this may change in the
183188
# future. This means the callback will never fire
184-
('Key_Play', [], None),
185-
('Key_Backspace', [], 'backspace'),
186-
('Key_Backspace', ['ControlModifier'], 'ctrl+backspace'),
189+
("Key_Play", [], None),
190+
("Key_Backspace", [], "backspace"),
191+
(
192+
"Key_Backspace",
193+
["ControlModifier"],
194+
"ctrl+backspace",
195+
),
187196
],
188197
ids=[
189198
'shift',
@@ -216,6 +225,11 @@ def test_correct_key(backend, qt_core, qt_key, qt_mods, answer):
216225
Assert sent and caught keys are the same.
217226
"""
218227
from matplotlib.backends.qt_compat import _enum, _to_int
228+
229+
if sys.platform == "darwin" and answer is not None:
230+
answer = answer.replace("ctrl", "cmd")
231+
answer = answer.replace("control", "cmd")
232+
answer = answer.replace("meta", "ctrl")
219233
result = None
220234
qt_mod = _enum("QtCore.Qt.KeyboardModifier").NoModifier
221235
for mod in qt_mods:

0 commit comments

Comments
 (0)