Skip to content

Commit 2e20058

Browse files
committed
Make test_stem 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 4764452 commit 2e20058

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3342,10 +3342,15 @@ def test_hist_stacked_weighted():
33423342
ax.hist((d1, d2), weights=(w1, w2), histtype="stepfilled", stacked=True)
33433343

33443344

3345-
@pytest.mark.parametrize("use_line_collection", [True, False],
3346-
ids=['w/ line collection', 'w/o line collection'])
3347-
@image_comparison(['stem.png'], style='mpl20', remove_text=True)
3348-
def test_stem(use_line_collection):
3345+
@image_comparison(['stem.png', 'stem.png'], style='mpl20', remove_text=True)
3346+
def test_stem():
3347+
# Note, we don't use @pytest.mark.parametrize, because in parallel this
3348+
# might cause one process result to overwrite another's.
3349+
for use_line_collection in [True, False]:
3350+
_test_stem(use_line_collection)
3351+
3352+
3353+
def _test_stem(use_line_collection):
33493354
x = np.linspace(0.1, 2 * np.pi, 100)
33503355
args = (x, np.cos(x))
33513356
# Label is a single space to force a legend to be drawn, but to avoid any

0 commit comments

Comments
 (0)