|
11 | 11 | import re |
12 | 12 | import sys |
13 | 13 | from types import SimpleNamespace |
| 14 | +import unittest.mock |
14 | 15 |
|
15 | 16 | import dateutil.tz |
16 | 17 |
|
|
45 | 46 | from matplotlib.testing.decorators import ( |
46 | 47 | image_comparison, check_figures_equal, remove_ticks_and_titles) |
47 | 48 | from matplotlib.testing._markers import needs_usetex |
48 | | - |
49 | 49 | # Note: Some test cases are run twice: once normally and once with labeled data |
50 | 50 | # These two must be defined in the same test function or need to have |
51 | 51 | # different baseline images to prevent race conditions when pytest runs |
@@ -10018,3 +10018,20 @@ def test_pie_all_zeros(): |
10018 | 10018 | fig, ax = plt.subplots() |
10019 | 10019 | with pytest.raises(ValueError, match="All wedge sizes are zero"): |
10020 | 10020 | ax.pie([0, 0], labels=["A", "B"]) |
| 10021 | + |
| 10022 | + |
| 10023 | +def test_animated_artists_not_drawn_by_default(): |
| 10024 | + fig, (ax1, ax2) = plt.subplots(ncols=2) |
| 10025 | + |
| 10026 | + imdata = np.random.random((20, 20)) |
| 10027 | + lndata = imdata[0] |
| 10028 | + |
| 10029 | + im = ax1.imshow(imdata, animated=True) |
| 10030 | + (ln,) = ax2.plot(lndata, animated=True) |
| 10031 | + |
| 10032 | + with (unittest.mock.patch.object(im, "draw", name="im.draw") as mocked_im_draw, |
| 10033 | + unittest.mock.patch.object(ln, "draw", name="ln.draw") as mocked_ln_draw): |
| 10034 | + fig.draw_without_rendering() |
| 10035 | + |
| 10036 | + mocked_im_draw.assert_not_called() |
| 10037 | + mocked_ln_draw.assert_not_called() |
0 commit comments