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

Skip to content

Commit 957abbb

Browse files
committed
Make test_imagegrid_cbar_mode_edge less flaky.
Since parametrizing the test allows it to run in parallel, this makes it flaky, as one process can overwrite the test result image of another. Our standard way for dealing with tests that use the same baseline image is to pass duplicate filenames to `image_comparison`, because that is serialized.
1 parent cfd5463 commit 957abbb

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/mpl_toolkits/tests/test_axes_grid.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@
1212
# The original version of this test relied on mpl_toolkits's slightly different
1313
# colorbar implementation; moving to matplotlib's own colorbar implementation
1414
# caused the small image comparison error.
15-
@pytest.mark.parametrize("legacy_colorbar", [False, True])
16-
@image_comparison(['imagegrid_cbar_mode.png'],
15+
@image_comparison(['imagegrid_cbar_mode.png'] * 2,
1716
remove_text=True, style='mpl20', tol=0.3)
18-
def test_imagegrid_cbar_mode_edge(legacy_colorbar):
17+
def test_imagegrid_cbar_mode_edge():
18+
# Note, we don't use @pytest.mark.parametrize, because in parallel this
19+
# might cause one process result to overwrite another's.
20+
for legacy_colorbar in [False, True]:
21+
_test_imagegrid_cbar_mode_edge(legacy_colorbar)
22+
23+
24+
def _test_imagegrid_cbar_mode_edge(legacy_colorbar):
1925
mpl.rcParams["mpl_toolkits.legacy_colorbar"] = legacy_colorbar
2026

2127
X, Y = np.meshgrid(np.linspace(0, 6, 30), np.linspace(0, 6, 30))

0 commit comments

Comments
 (0)