Skip to content

Commit 781372e

Browse files
committed
force plotting backend of tests to "agg"
1 parent d61b3d8 commit 781372e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

tests/conftest.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import logging
2-
31
import keras
2+
import logging
3+
import matplotlib
44
import pytest
55

66
BACKENDS = ["jax", "numpy", "tensorflow", "torch"]
@@ -17,6 +17,16 @@ def pytest_runtest_setup(item):
1717
if test_backends and backend not in test_backends:
1818
pytest.skip(f"Skipping backend '{backend}' for test {item}, which is registered for backends {test_backends}.")
1919

20+
# use a non-GUI plotting backend for tests
21+
matplotlib.use("Agg")
22+
23+
24+
def pytest_runtest_teardown(item, nextitem):
25+
import matplotlib.pyplot as plt
26+
27+
# close all plots at the end of each test
28+
plt.close("all")
29+
2030

2131
def pytest_make_parametrize_id(config, val, argname):
2232
return f"{argname}={repr(val)}"

0 commit comments

Comments
 (0)