@@ -179,11 +179,7 @@ def _has_tex_package(package):
179
179
return False
180
180
181
181
182
- def ipython_in_subprocess (
183
- requested_backend_or_gui_framework ,
184
- expected_backend_old_ipython , # IPython < 8.24
185
- expected_backend_new_ipython , # IPython >= 8.24
186
- ):
182
+ def ipython_in_subprocess (requested_backend_or_gui_framework , all_expected_backends ):
187
183
import pytest
188
184
IPython = pytest .importorskip ("IPython" )
189
185
@@ -194,12 +190,12 @@ def ipython_in_subprocess(
194
190
requested_backend_or_gui_framework == "osx" ):
195
191
pytest .skip ("Bug using macosx backend in IPython 8.24.0 fixed in 8.24.1" )
196
192
197
- if IPython . version_info [: 2 ] >= ( 8 , 24 ):
198
- expected_backend = expected_backend_new_ipython
199
- else :
200
- # This code can be removed when Python 3.12, the latest version supported by
201
- # IPython < 8.24, reaches end-of-life in late 2028.
202
- expected_backend = expected_backend_old_ipython
193
+ # This code can be removed when Python 3.12, the latest version supported
194
+ # by IPython < 8.24, reaches end-of-life in late 2028.
195
+ for min_version , backend in all_expected_backends . items () :
196
+ if IPython . version_info [: 2 ] >= min_version :
197
+ expected_backend = backend
198
+ break
203
199
204
200
code = ("import matplotlib as mpl, matplotlib.pyplot as plt;"
205
201
"fig, ax=plt.subplots(); ax.plot([1, 3, 2]); mpl.get_backend()" )
@@ -214,4 +210,4 @@ def ipython_in_subprocess(
214
210
capture_output = True ,
215
211
)
216
212
217
- assert proc .stdout .strip () == f"Out[1]: '{ expected_backend } '"
213
+ assert proc .stdout .strip (). endswith ( f" '{ expected_backend } '")
0 commit comments