Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 85a4a72

Browse files
committed
TST: Use explicit style in all image_comparison calls
This makes it so that future tests *must* use the new style (or explicitly opt in to the old), and in the future, we may return to a default of that one instead. Fixes #24716
1 parent 3322808 commit 85a4a72

39 files changed

Lines changed: 488 additions & 271 deletions

lib/matplotlib/testing/decorators.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,7 @@ def wrapper(*args, extension, request, **kwargs):
260260
def image_comparison(baseline_images, extensions=None, tol=0,
261261
freetype_version=None, remove_text=False,
262262
savefig_kwarg=None,
263-
# Default of mpl_test_settings fixture and cleanup too.
264-
style=("classic", "_classic_test_patch")):
263+
*, style):
265264
"""
266265
Compare images generated by the test with those specified in
267266
*baseline_images*, which must correspond, else an `.ImageComparisonFailure`

lib/matplotlib/testing/decorators.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ def image_comparison(
1717
freetype_version: tuple[str, str] | str | None = ...,
1818
remove_text: bool = ...,
1919
savefig_kwarg: dict[str, Any] | None = ...,
20-
style: RcStyleType = ...,
20+
*,
21+
style: RcStyleType,
2122
) -> Callable[[Callable[_P, _R]], Callable[_P, _R]]: ...
2223
def check_figures_equal(
2324
*, extensions: Sequence[str] = ..., tol: float = ...

lib/matplotlib/tests/test_agg.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ def test_long_path():
9292
fig.savefig(buff, format='png')
9393

9494

95-
@image_comparison(['agg_filter.png'], remove_text=True)
95+
@image_comparison(['agg_filter.png'], remove_text=True,
96+
style=('classic', '_classic_test_patch'))
9697
def test_agg_filter():
9798
def smooth1d(x, window_len):
9899
# copied from https://scipy-cookbook.readthedocs.io/

lib/matplotlib/tests/test_agg_filter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66

77
@image_comparison(baseline_images=['agg_filter_alpha'],
8-
extensions=['gif', 'png', 'pdf'])
8+
extensions=['gif', 'png', 'pdf'],
9+
style=('classic', '_classic_test_patch'))
910
def test_agg_filter_alpha():
1011
# Remove this line when this test image is regenerated.
1112
plt.rcParams['pcolormesh.snap'] = False

lib/matplotlib/tests/test_arrow_patches.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def draw_arrow(ax, t, r):
1212

1313

1414
@image_comparison(['fancyarrow_test_image.png'],
15+
style=('classic', '_classic_test_patch'),
1516
tol=0 if platform.machine() == 'x86_64' else 0.012)
1617
def test_fancyarrow():
1718
# Added 0 to test division by zero error described in issue 3930
@@ -28,7 +29,7 @@ def test_fancyarrow():
2829
ax.tick_params(labelleft=False, labelbottom=False)
2930

3031

31-
@image_comparison(['boxarrow_test_image.png'])
32+
@image_comparison(['boxarrow_test_image.png'], style=('classic', '_classic_test_patch'))
3233
def test_boxarrow():
3334

3435
styles = mpatches.BoxStyle.get_styles()
@@ -68,8 +69,8 @@ def __prepare_fancyarrow_dpi_cor_test():
6869

6970

7071
@image_comparison(['fancyarrow_dpi_cor_100dpi.png'], remove_text=True,
71-
tol=0 if platform.machine() == 'x86_64' else 0.02,
72-
savefig_kwarg=dict(dpi=100))
72+
savefig_kwarg=dict(dpi=100), style=('classic', '_classic_test_patch'),
73+
tol=0 if platform.machine() == 'x86_64' else 0.02)
7374
def test_fancyarrow_dpi_cor_100dpi():
7475
"""
7576
Check the export of a FancyArrowPatch @ 100 DPI. FancyArrowPatch is
@@ -83,8 +84,8 @@ def test_fancyarrow_dpi_cor_100dpi():
8384

8485

8586
@image_comparison(['fancyarrow_dpi_cor_200dpi.png'], remove_text=True,
86-
tol=0 if platform.machine() == 'x86_64' else 0.02,
87-
savefig_kwarg=dict(dpi=200))
87+
savefig_kwarg=dict(dpi=200), style=('classic', '_classic_test_patch'),
88+
tol=0 if platform.machine() == 'x86_64' else 0.02)
8889
def test_fancyarrow_dpi_cor_200dpi():
8990
"""
9091
As test_fancyarrow_dpi_cor_100dpi, but exports @ 200 DPI. The relative size

lib/matplotlib/tests/test_artist.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ def test_collection_transform_of_none():
9696
assert isinstance(c.get_offset_transform(), mtransforms.IdentityTransform)
9797

9898

99-
@image_comparison(["clip_path_clipping"], remove_text=True)
99+
@image_comparison(["clip_path_clipping"], remove_text=True,
100+
style=('classic', '_classic_test_patch'))
100101
def test_clipping():
101102
exterior = mpath.Path.unit_rectangle().deepcopy()
102103
exterior.vertices *= 4

0 commit comments

Comments
 (0)