File tree 1 file changed +20
-0
lines changed 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -343,6 +343,26 @@ def test_qt5backends_uses_qt5():
343
343
_run_helper (_implcore , timeout = _test_timeout )
344
344
345
345
346
+ def _impl_missing ():
347
+ import sys
348
+ # Simulate uninstalled
349
+ sys .modules ["PyQt6" ] = None
350
+ sys .modules ["PyQt5" ] = None
351
+ sys .modules ["PySide2" ] = None
352
+ sys .modules ["PySide6" ] = None
353
+
354
+ import matplotlib .pyplot as plt
355
+ with pytest .raises (ImportError , match = "Failed to import any of the following Qt" ):
356
+ plt .switch_backend ("qtagg" )
357
+ # Specifically ensure that Pyside6/Pyqt6 are not in the error message for qt5agg
358
+ with pytest .raises (ImportError , match = "^(?:(?!(PySide6|PyQt6)).)*$" ):
359
+ plt .switch_backend ("qt5agg" )
360
+
361
+
362
+ def test_qt_missing ():
363
+ _run_helper (_impl_missing , timeout = _test_timeout )
364
+
365
+
346
366
def _impl_test_cross_Qt_imports ():
347
367
import sys
348
368
import importlib
You can’t perform that action at this time.
0 commit comments