@@ -107,7 +107,8 @@ def _test_interactive_impl():
107
107
import io
108
108
import json
109
109
import sys
110
- from unittest import TestCase
110
+
111
+ import pytest
111
112
112
113
import matplotlib as mpl
113
114
from matplotlib import pyplot as plt
@@ -119,8 +120,6 @@ def _test_interactive_impl():
119
120
120
121
mpl .rcParams .update (json .loads (sys .argv [1 ]))
121
122
backend = plt .rcParams ["backend" ].lower ()
122
- assert_equal = TestCase ().assertEqual
123
- assert_raises = TestCase ().assertRaises
124
123
125
124
if backend .endswith ("agg" ) and not backend .startswith (("gtk" , "web" )):
126
125
# Force interactive framework setup.
@@ -135,25 +134,24 @@ def _test_interactive_impl():
135
134
# uses no interactive framework).
136
135
137
136
if backend != "tkagg" :
138
- with assert_raises (ImportError ):
137
+ with pytest . raises (ImportError ):
139
138
mpl .use ("tkagg" , force = True )
140
139
141
140
def check_alt_backend (alt_backend ):
142
141
mpl .use (alt_backend , force = True )
143
142
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 } " )
147
145
148
146
if importlib .util .find_spec ("cairocffi" ):
149
147
check_alt_backend (backend [:- 3 ] + "cairo" )
150
148
check_alt_backend ("svg" )
151
149
mpl .use (backend , force = True )
152
150
153
151
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"
157
155
158
156
if mpl .rcParams ["toolbar" ] == "toolmanager" :
159
157
# test toolbar button icon LA mode see GH issue 25174
@@ -189,7 +187,7 @@ def check_alt_backend(alt_backend):
189
187
if not backend .startswith ('qt5' ) and sys .platform == 'darwin' :
190
188
# FIXME: This should be enabled everywhere once Qt5 is fixed on macOS
191
189
# to not resize incorrectly.
192
- assert_equal ( result .getvalue (), result_after .getvalue () )
190
+ assert result .getvalue () == result_after .getvalue ()
193
191
194
192
195
193
@pytest .mark .parametrize ("env" , _get_testable_interactive_backends ())
@@ -241,7 +239,7 @@ def _test_thread_impl():
241
239
future .result () # Joins the thread; rethrows any exception.
242
240
plt .close () # backend is responsible for flushing any events here
243
241
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
245
243
fig .canvas .flush_events ()
246
244
247
245
0 commit comments