@@ -107,7 +107,8 @@ def _test_interactive_impl():
107107 import io
108108 import json
109109 import sys
110- from unittest import TestCase
110+
111+ import pytest
111112
112113 import matplotlib as mpl
113114 from matplotlib import pyplot as plt
@@ -119,8 +120,6 @@ def _test_interactive_impl():
119120
120121 mpl .rcParams .update (json .loads (sys .argv [1 ]))
121122 backend = plt .rcParams ["backend" ].lower ()
122- assert_equal = TestCase ().assertEqual
123- assert_raises = TestCase ().assertRaises
124123
125124 if backend .endswith ("agg" ) and not backend .startswith (("gtk" , "web" )):
126125 # Force interactive framework setup.
@@ -135,25 +134,24 @@ def _test_interactive_impl():
135134 # uses no interactive framework).
136135
137136 if backend != "tkagg" :
138- with assert_raises (ImportError ):
137+ with pytest . raises (ImportError ):
139138 mpl .use ("tkagg" , force = True )
140139
141140 def check_alt_backend (alt_backend ):
142141 mpl .use (alt_backend , force = True )
143142 fig = plt .figure ()
144- assert_equal (
145- type (fig .canvas ).__module__ ,
146- f"matplotlib.backends.backend_{ alt_backend } " )
143+ assert (type (fig .canvas ).__module__ ==
144+ f"matplotlib.backends.backend_{ alt_backend } " )
147145
148146 if importlib .util .find_spec ("cairocffi" ):
149147 check_alt_backend (backend [:- 3 ] + "cairo" )
150148 check_alt_backend ("svg" )
151149 mpl .use (backend , force = True )
152150
153151 fig , ax = plt .subplots ()
154- assert_equal (
155- type ( fig . canvas ). __module__ ,
156- f"matplotlib.backends.backend_ { backend } " )
152+ assert type ( fig . canvas ). __module__ == f"matplotlib.backends.backend_ { backend } "
153+
154+ assert fig . canvas . manager . get_window_title () == "Figure 1"
157155
158156 if mpl .rcParams ["toolbar" ] == "toolmanager" :
159157 # test toolbar button icon LA mode see GH issue 25174
@@ -189,7 +187,7 @@ def check_alt_backend(alt_backend):
189187 if not backend .startswith ('qt5' ) and sys .platform == 'darwin' :
190188 # FIXME: This should be enabled everywhere once Qt5 is fixed on macOS
191189 # to not resize incorrectly.
192- assert_equal ( result .getvalue (), result_after .getvalue () )
190+ assert result .getvalue () == result_after .getvalue ()
193191
194192
195193@pytest .mark .parametrize ("env" , _get_testable_interactive_backends ())
@@ -241,7 +239,7 @@ def _test_thread_impl():
241239 future .result () # Joins the thread; rethrows any exception.
242240 plt .close () # backend is responsible for flushing any events here
243241 if plt .rcParams ["backend" ].startswith ("WX" ):
244- # TODO: debug why WX needs this only on py3 .8
242+ # TODO: debug why WX needs this only on py >= 3 .8
245243 fig .canvas .flush_events ()
246244
247245
0 commit comments