15
15
from matplotlib import _c_internal_utils
16
16
17
17
try :
18
+ from matplotlib .backends .qt_compat import QtCore
18
19
from matplotlib .backends .qt_compat import QtGui # type: ignore[attr-defined] # noqa: E501, F401
19
20
from matplotlib .backends .qt_compat import QtWidgets # type: ignore[attr-defined]
20
21
from matplotlib .backends .qt_editor import _formlayout
25
26
_test_timeout = 60 # A reasonably safe value for slower architectures.
26
27
27
28
28
- @pytest .fixture
29
- def qt_core (request ):
30
- from matplotlib .backends .qt_compat import QtCore
31
- return QtCore
32
-
33
-
34
29
@pytest .mark .backend ('QtAgg' , skip_on_importerror = True )
35
30
def test_fig_close ():
36
31
@@ -101,7 +96,7 @@ def test_fig_close():
101
96
'QtAgg' ,
102
97
marks = pytest .mark .backend ('QtAgg' , skip_on_importerror = True )),
103
98
])
104
- def test_correct_key (backend , qt_core , qt_key , qt_mods , answer , monkeypatch ):
99
+ def test_correct_key (backend , qt_key , qt_mods , answer , monkeypatch ):
105
100
"""
106
101
Make a figure.
107
102
Send a key_press_event event (using non-public, qtX backend specific api).
@@ -137,7 +132,7 @@ def on_key_press(event):
137
132
138
133
139
134
@pytest .mark .backend ('QtAgg' , skip_on_importerror = True )
140
- def test_device_pixel_ratio_change (qt_core ):
135
+ def test_device_pixel_ratio_change ():
141
136
"""
142
137
Make sure that if the pixel ratio changes, the figure dpi changes but the
143
138
widget remains the same logical size.
@@ -155,12 +150,11 @@ def set_device_pixel_ratio(ratio):
155
150
p .return_value = ratio
156
151
157
152
window = qt_canvas .window ().windowHandle ()
158
- current_version = tuple (
159
- int (x ) for x in qt_core .qVersion ().split ('.' , 2 )[:2 ])
153
+ current_version = tuple (int (x ) for x in QtCore .qVersion ().split ('.' , 2 )[:2 ])
160
154
if current_version >= (6 , 6 ):
161
- qt_core .QCoreApplication .sendEvent (
155
+ QtCore .QCoreApplication .sendEvent (
162
156
window ,
163
- qt_core .QEvent (qt_core .QEvent .Type .DevicePixelRatioChange ))
157
+ QtCore .QEvent (QtCore .QEvent .Type .DevicePixelRatioChange ))
164
158
else :
165
159
# The value here doesn't matter, as we can't mock the C++ QScreen
166
160
# object, but can override the functional wrapper around it.
@@ -342,7 +336,7 @@ def _get_testable_qt_backends():
342
336
343
337
344
338
@pytest .mark .backend ('QtAgg' , skip_on_importerror = True )
345
- def test_fig_sigint_override (qt_core ):
339
+ def test_fig_sigint_override ():
346
340
from matplotlib .backends .backend_qt5 import _BackendQT5
347
341
# Create a figure
348
342
plt .figure ()
@@ -357,10 +351,10 @@ def fire_signal_and_quit():
357
351
event_loop_handler = signal .getsignal (signal .SIGINT )
358
352
359
353
# Request event loop exit
360
- qt_core .QCoreApplication .exit ()
354
+ QtCore .QCoreApplication .exit ()
361
355
362
356
# Timer to exit event loop
363
- qt_core .QTimer .singleShot (0 , fire_signal_and_quit )
357
+ QtCore .QTimer .singleShot (0 , fire_signal_and_quit )
364
358
365
359
# Save original SIGINT handler
366
360
original_handler = signal .getsignal (signal .SIGINT )
@@ -385,7 +379,7 @@ def custom_handler(signum, frame):
385
379
386
380
# Repeat again to test that SIG_DFL and SIG_IGN will not be overridden
387
381
for custom_handler in (signal .SIG_DFL , signal .SIG_IGN ):
388
- qt_core .QTimer .singleShot (0 , fire_signal_and_quit )
382
+ QtCore .QTimer .singleShot (0 , fire_signal_and_quit )
389
383
signal .signal (signal .SIGINT , custom_handler )
390
384
391
385
_BackendQT5 .mainloop ()
0 commit comments