1515from matplotlib import _c_internal_utils
1616
1717try :
18+ from matplotlib .backends .qt_compat import QtCore # type: ignore[attr-defined]
1819 from matplotlib .backends .qt_compat import QtGui # type: ignore[attr-defined] # noqa: E501, F401
1920 from matplotlib .backends .qt_compat import QtWidgets # type: ignore[attr-defined]
2021 from matplotlib .backends .qt_editor import _formlayout
2526_test_timeout = 60 # A reasonably safe value for slower architectures.
2627
2728
28- @pytest .fixture
29- def qt_core (request ):
30- from matplotlib .backends .qt_compat import QtCore
31- return QtCore
32-
33-
3429@pytest .mark .backend ('QtAgg' , skip_on_importerror = True )
3530def test_fig_close ():
3631
@@ -101,7 +96,7 @@ def test_fig_close():
10196 'QtAgg' ,
10297 marks = pytest .mark .backend ('QtAgg' , skip_on_importerror = True )),
10398])
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 ):
105100 """
106101 Make a figure.
107102 Send a key_press_event event (using non-public, qtX backend specific api).
@@ -137,7 +132,7 @@ def on_key_press(event):
137132
138133
139134@pytest .mark .backend ('QtAgg' , skip_on_importerror = True )
140- def test_device_pixel_ratio_change (qt_core ):
135+ def test_device_pixel_ratio_change ():
141136 """
142137 Make sure that if the pixel ratio changes, the figure dpi changes but the
143138 widget remains the same logical size.
@@ -155,12 +150,11 @@ def set_device_pixel_ratio(ratio):
155150 p .return_value = ratio
156151
157152 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 ])
160154 if current_version >= (6 , 6 ):
161- qt_core .QCoreApplication .sendEvent (
155+ QtCore .QCoreApplication .sendEvent (
162156 window ,
163- qt_core .QEvent (qt_core .QEvent .Type .DevicePixelRatioChange ))
157+ QtCore .QEvent (QtCore .QEvent .Type .DevicePixelRatioChange ))
164158 else :
165159 # The value here doesn't matter, as we can't mock the C++ QScreen
166160 # object, but can override the functional wrapper around it.
@@ -342,7 +336,7 @@ def _get_testable_qt_backends():
342336
343337
344338@pytest .mark .backend ('QtAgg' , skip_on_importerror = True )
345- def test_fig_sigint_override (qt_core ):
339+ def test_fig_sigint_override ():
346340 from matplotlib .backends .backend_qt5 import _BackendQT5
347341 # Create a figure
348342 plt .figure ()
@@ -357,10 +351,10 @@ def fire_signal_and_quit():
357351 event_loop_handler = signal .getsignal (signal .SIGINT )
358352
359353 # Request event loop exit
360- qt_core .QCoreApplication .exit ()
354+ QtCore .QCoreApplication .exit ()
361355
362356 # Timer to exit event loop
363- qt_core .QTimer .singleShot (0 , fire_signal_and_quit )
357+ QtCore .QTimer .singleShot (0 , fire_signal_and_quit )
364358
365359 # Save original SIGINT handler
366360 original_handler = signal .getsignal (signal .SIGINT )
@@ -385,7 +379,7 @@ def custom_handler(signum, frame):
385379
386380 # Repeat again to test that SIG_DFL and SIG_IGN will not be overridden
387381 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 )
389383 signal .signal (signal .SIGINT , custom_handler )
390384
391385 _BackendQT5 .mainloop ()
0 commit comments