diff --git a/properties/test_plotting.py b/properties/test_plotting.py index cf2076ebe96..4433a1621b3 100644 --- a/properties/test_plotting.py +++ b/properties/test_plotting.py @@ -6,9 +6,14 @@ 2. Plotting is stateful, so we have to clean up after each call With those details taken care of, they all pass! +Note also that a pytest teardown fixture (or unittest method) would not work +here, as they run once per test and we need to clean up once per *example*. + """ from __future__ import absolute_import, division, print_function +import matplotlib +matplotlib.use('Agg') import matplotlib.pyplot as plt from hypothesis import given, settings @@ -39,22 +44,26 @@ def test_imshow(arr): # Note that we clear the plot after each call - otherwise we just get # errors from polluting state with too many colormaps! xr.DataArray(arr).plot.imshow() + plt.draw() plt.clf() @given(two_dimensional_array) def test_pcolormesh(arr): xr.DataArray(arr).plot.pcolormesh() + plt.draw() plt.clf() @given(two_dimensional_array) def test_contour(arr): xr.DataArray(arr).plot.contour() + plt.draw() plt.clf() @given(two_dimensional_array) def test_contourf(arr): xr.DataArray(arr).plot.contourf() + plt.draw() plt.clf()