Skip to content

Commit c98bf73

Browse files
authored
use figure_context for tests (#37)
1 parent 306105d commit c98bf73

File tree

4 files changed

+257
-264
lines changed

4 files changed

+257
-264
lines changed

mplotutils/tests/__init__.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import contextlib
2+
3+
import matplotlib.pyplot as plt
4+
5+
6+
@contextlib.contextmanager
7+
def figure_context(*args, **kwargs):
8+
fig = plt.figure(*args, **kwargs)
9+
10+
try:
11+
yield fig
12+
finally:
13+
plt.close(fig)
14+
15+
16+
@contextlib.contextmanager
17+
def subplots_context(*args, **kwargs):
18+
fig, axs = plt.subplots(*args, **kwargs)
19+
20+
try:
21+
yield fig, axs
22+
finally:
23+
plt.close(fig)

0 commit comments

Comments
 (0)