diff --git a/pandas/tests/plotting/conftest.py b/pandas/tests/plotting/conftest.py index aa9952db17b74..6f77356eb3762 100644 --- a/pandas/tests/plotting/conftest.py +++ b/pandas/tests/plotting/conftest.py @@ -7,6 +7,13 @@ ) +@pytest.fixture(autouse=True) +def non_interactive(): + mpl = pytest.importorskip("matplotlib") + mpl.use("template") + yield + + @pytest.fixture(autouse=True) def reset_rcParams(): mpl = pytest.importorskip("matplotlib") @@ -16,8 +23,11 @@ def reset_rcParams(): @pytest.fixture(autouse=True) def close_all_figures(): + # https://stackoverflow.com/q/31156578 yield plt = pytest.importorskip("matplotlib.pyplot") + plt.cla() + plt.clf() plt.close("all")