diff --git a/conftest.py b/conftest.py index 5ae7aacb8e9e52e8f7672d1b6b77a2c0ff91c546..c989bd81b7443900b7e4d2953b5be6ea73763b91 100644 --- a/conftest.py +++ b/conftest.py @@ -111,14 +111,20 @@ class IPyNbTest(pytest.Item): # in notebooks there is an implicit plt.show() - if this is not called a warning is shown when the next # plot is created. This warning is suppressed here + # Also animations cannot be shown, which also leads to a warning. exec("import warnings;" - "warnings.filterwarnings('ignore', 'Adding an axes using the same arguments as a previous.*');", + "warnings.filterwarnings('ignore', 'Adding an axes using the same arguments as a previous.*');" + "warnings.filterwarnings('ignore', 'Animation was deleted without rendering anything.*');", global_dict) with tempfile.NamedTemporaryFile() as f: f.write(self.code.encode()) f.flush() runpy.run_path(f.name, init_globals=global_dict, run_name=self.name) + # Close any open figures + exec("import matplotlib.pyplot as p; " + "p.close('all')", global_dict) + class IPyNbFile(pytest.File): def collect(self):