Skip to content

Commit 5a164a6

Browse files
authored
tests: ensure all figures are closed (#38)
1 parent c98bf73 commit 5a164a6

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

mplotutils/tests/conftest.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import matplotlib.pyplot as plt
2+
import pytest
3+
4+
5+
@pytest.fixture(scope="function", autouse=True)
6+
def assert_all_figures_closed():
7+
"""meta-test to ensure all figures are closed at the end of a test"""
8+
yield None
9+
10+
open_figs = len(plt.get_fignums())
11+
if open_figs:
12+
raise RuntimeError(
13+
f"tests did not close all figures ({open_figs} figures open)"
14+
)

mplotutils/tests/test_set_map_layout.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import matplotlib.pyplot as plt
21
import numpy as np
32
import pytest
43

@@ -79,7 +78,6 @@ def test_vert_borders():
7978

8079
# width:height = 1:1
8180
with subplots_context() as (f, ax):
82-
f, ax = plt.subplots()
8381
ax.set_aspect("equal")
8482
ax.set(xlim=(0, 1), ylim=(0, 1))
8583

0 commit comments

Comments
 (0)