8000 add ion/ioff context manager tests · matplotlib/matplotlib@7277226 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7277226

Browse files
committed
add ion/ioff context manager tests
need to ensure that the original state is restored post contextmanager
1 parent 2458155 commit 7277226

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

lib/matplotlib/tests/test_pyplot.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,27 @@ def test_nrows_error():
8181
plt.subplot(nrows=1)
8282
with pytest.raises(TypeError):
8383
plt.subplot(ncols=1)
84+
85+
86+
def test_ioff_context():
87+
mpl.interactive(True)
88+
with plt.ioff():
89+
assert not mpl.is_interactive
90+
assert mpl.is_interactive
91+
92+
mpl.interactive(False)
93+
with plt.ioff():
94+
assert not mpl.is_interactive
95+
assert not mpl.is_interactive
96+
97+
98+
def test_ion_context():
99+
mpl.interactive(False)
100+
with plt.ioff():
101+
assert mpl.is_interactive
102+
assert not mpl.is_interactive
103+
104+
mpl.interactive(True)
105+
with plt.ion():
106+
assert not mpl.is_interactive
107+
assert mpl.is_interactive

0 commit comments

Comments
 (0)
0