@@ -23,6 +23,7 @@ def _run_function_in_subprocess(func):
23
23
return f"{ func_source } \n { func .__name__ } ()"
24
24
25
25
26
+
26
27
# Minimal smoke-testing of the backends for which the dependencies are
27
28
# PyPI-installable on CI. They are not available for all tested Python
28
29
# versions so we don't fail on missing backends.
@@ -344,6 +345,50 @@ def _implcore():
344
345
stdout = subprocess .PIPE , universal_newlines = True )
345
346
346
347
348
+ def _impl_test_cross_Qt_imports ():
349
+ import sys
350
+ import importlib
351
+ import pytest
352
+
353
+ _ , host_binding , mpl_binding = sys .argv
354
+ # import the mpl binding. This will force us to use that binding
355
+ importlib .import_module (f'{ mpl_binding } .QtCore' )
356
+ mpl_binding_qwidgets = importlib .import_module (f'{ mpl_binding } .QtWidgets' )
357
+ import matplotlib .backends .backend_qt
358
+ host_qwidgets = importlib .import_module (f'{ host_binding } .QtWidgets' )
359
+
360
+ host_app = host_qwidgets .QApplication (["mpl testing" ])
361
+ with pytest .warns (UserWarning , match = "Mixing Qt major" ):
362
+ matplotlib .backends .backend_qt ._create_qApp ()
363
+
364
+
365
+ def test_cross_Qt_imports ():
366
+ qt5_bindings = [
367
+ dep for dep in ['PyQt5' , 'PySide2' ]
368
+ if importlib .util .find_spec (dep ) is not None
369
+ ]
370
+ qt6_bindings = [
371
+ dep for dep in ['PyQt6' , 'PySide6' ]
372
+ if importlib .util .find_spec (dep ) is not None
373
+ ]
374
+ if len (qt5_bindings ) == 0 or len (qt6_bindings ) == 0 :
375
+ pytest .skip ('need both QT6 and QT5 bindings' )
376
+
377
+ for qt5 in qt5_bindings :
378
+ for qt6 in qt6_bindings :
379
+ for pair in ([qt5 , qt6 ], [qt6 , qt5 ]):
380
+ try :
381
+ _run_helper (__name__ , _impl_test_cross_Qt_imports ,
382
+ * pair ,
383
+ timeout = _test_timeout )
384
+ except subprocess .CalledProcessError as ex :
385
+ # if segfauldt, carry on. We do try to warn the user they
386
+ # are doing something that we do not expect to work
387
+ if ex .returncode == - 11 :
388
+ continue
389
+ raise
390
+
391
+
347
392
@pytest .mark .skipif ('TF_BUILD' in os .environ ,
348
393
reason = "this test fails an azure for unknown reasons" )
349
394
@pytest .mark .skipif (os .name == "nt" , reason = "Cannot send SIGINT on Windows." )
0 commit comments