1414import matplotlib .style
1515import matplotlib .units
1616import matplotlib .testing
17- from matplotlib import _pylab_helpers , cbook , ft2font , pyplot as plt , ticker
17+ from matplotlib import _api , _pylab_helpers , cbook , ft2font , pyplot as plt , ticker
1818from matplotlib .figure import Figure
1919from .compare import comparable_formats , compare_images , make_test_filename
2020from .exceptions import ImageComparisonFailure
@@ -263,8 +263,7 @@ def wrapper(*args, extension, request, **kwargs):
263263def image_comparison (baseline_images , extensions = None , tol = 0 ,
264264 freetype_version = None , remove_text = False ,
265265 savefig_kwarg = None ,
266- # Default of mpl_test_settings fixture and cleanup too.
267- style = ("classic" , "_classic_test_patch" )):
266+ style = None ):
268267 """
269268 Compare images generated by the test with those specified in
270269 *baseline_images*, which must correspond, else an `.ImageComparisonFailure`
@@ -316,9 +315,13 @@ def image_comparison(baseline_images, extensions=None, tol=0,
316315 Optional arguments that are passed to the savefig method.
317316
318317 style : str, dict, or list
319- The optional style(s) to apply to the image test. The test itself
320- can also apply additional styles if desired. Defaults to ``["classic",
321- "_classic_test_patch"]``.
318+ The style(s) to apply to the image test. The test itself can also apply
319+ additional styles if desired.
320+
321+ .. versionchanged:: 3.11
322+ This defaults to ``['classic', '_classic_test_patch']``, but will be
323+ changing to ``'mpl20'`` as of Matplotlib 3.13. A warning is raised if not
324+ explicitly passed.
322325 """
323326
324327 if baseline_images is not None :
@@ -342,6 +345,12 @@ def image_comparison(baseline_images, extensions=None, tol=0,
342345 extensions = ['png' , 'pdf' , 'svg' ]
343346 if savefig_kwarg is None :
344347 savefig_kwarg = dict () # default no kwargs to savefig
348+ if style is None :
349+ _api .warn_external (
350+ 'The default for the style parameter of image_comparsion() will be '
351+ 'changing to "mpl20" in Matplotlib 3.13; explicitly pass style to continue '
352+ 'working as before and suppress this warning.' )
353+ style = ('classic' , '_classic_test_patch' )
345354 if sys .maxsize <= 2 ** 32 :
346355 tol += 0.06
347356 return _pytest_image_comparison (
0 commit comments