@@ -267,7 +267,9 @@ def _implqt5agg():
267
267
assert 'PyQt5' in sys .modules or 'pyside2' in sys .modules
268
268
269
269
import matplotlib .backends .backend_qt5
270
- matplotlib .backends .backend_qt5 .qApp
270
+ with pytest .warns (DeprecationWarning ,
271
+ match = "QtWidgets.QApplication.instance" ):
272
+ matplotlib .backends .backend_qt5 .qApp
271
273
272
274
273
275
def _implcairo ():
@@ -279,7 +281,9 @@ def _implcairo():
279
281
assert 'PyQt5' in sys .modules or 'pyside2' in sys .modules
280
282
281
283
import matplotlib .backends .backend_qt5
282
- matplotlib .backends .backend_qt5 .qApp
284
+ with pytest .warns (DeprecationWarning ,
285
+ match = "QtWidgets.QApplication.instance" ):
286
+ matplotlib .backends .backend_qt5 .qApp
283
287
284
288
285
289
def _implcore ():
@@ -289,7 +293,10 @@ def _implcore():
289
293
assert 'PyQt6' not in sys .modules
290
294
assert 'pyside6' not in sys .modules
291
295
assert 'PyQt5' in sys .modules or 'pyside2' in sys .modules
292
- matplotlib .backends .backend_qt5 .qApp
296
+
297
+ with pytest .warns (DeprecationWarning ,
298
+ match = "QtWidgets.QApplication.instance" ):
299
+ matplotlib .backends .backend_qt5 .qApp
293
300
294
301
295
302
def test_qt5backends_uses_qt5 ():
@@ -410,11 +417,25 @@ def _lazy_headless():
410
417
411
418
412
419
@pytest .mark .skipif (sys .platform != "linux" , reason = "this a linux-only test" )
413
- @pytest .mark .backend ('QtAgg ' , skip_on_importerror = True )
420
+ @pytest .mark .backend ('Qt5Agg ' , skip_on_importerror = True )
414
421
def test_lazy_linux_headless ():
415
422
proc = _run_helper (_lazy_headless , timeout = _test_timeout , MPLBACKEND = "" )
416
423
417
424
425
+ def _qApp_warn_impl ():
426
+ import matplotlib .backends .backend_qt
427
+ import pytest
428
+
429
+ with pytest .warns (
430
+ DeprecationWarning , match = "QtWidgets.QApplication.instance" ):
431
+ matplotlib .backends .backend_qt .qApp
432
+
433
+
434
+ @pytest .mark .backend ('QtAgg' , skip_on_importerror = True )
435
+ def test_qApp_warn ():
436
+ _run_helper (_qApp_warn_impl , timeout = _test_timeout )
437
+
438
+
418
439
def _test_number_of_draws_script ():
419
440
import matplotlib .pyplot as plt
420
441
0 commit comments