Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3f7dad4

Browse files
authored
Merge pull request #7765 from dstansby/figure-test-clean
TST: Clean up figure tests
2 parents 27bc177 + 8de6aab commit 3f7dad4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/matplotlib/tests/test_figure.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from matplotlib.axes import Axes
1111
import matplotlib.pyplot as plt
1212
import numpy as np
13+
import warnings
1314

1415

1516
@cleanup
@@ -83,7 +84,11 @@ def test_gca():
8384

8485
# the final request for a polar axes will end up creating one
8586
# with a spec of 111.
86-
assert_true(fig.gca(polar=True) is not ax3)
87+
with warnings.catch_warnings(record=True) as w:
88+
warnings.simplefilter('always')
89+
# Changing the projection will throw a warning
90+
assert_true(fig.gca(polar=True) is not ax3)
91+
assert len(w) == 1
8792
assert_true(fig.gca(polar=True) is not ax2)
8893
assert_equal(fig.gca().get_geometry(), (1, 1, 1))
8994

@@ -133,15 +138,14 @@ def test_alpha():
133138

134139
@cleanup
135140
def test_too_many_figures():
136-
import warnings
137-
138141
with warnings.catch_warnings(record=True) as w:
139142
warnings.simplefilter("always")
140143
for i in range(rcParams['figure.max_open_warning'] + 1):
141144
fig = plt.figure()
142145
assert len(w) == 1
143146

144147

148+
@cleanup
145149
def test_iterability_axes_argument():
146150

147151
# This is a regression test for matplotlib/matplotlib#3196. If one of the

0 commit comments

Comments
 (0)