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

Skip to content

Commit 7bd0a45

Browse files
committed
MAINT moved test_figure to pytest
1 parent 194afed commit 7bd0a45

2 files changed

Lines changed: 14 additions & 23 deletions

File tree

lib/matplotlib/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,6 @@ def _jupyter_nbextension_paths():
14951495
'matplotlib.tests.test_contour',
14961496
'matplotlib.tests.test_dates',
14971497
'matplotlib.tests.test_dviread',
1498-
'matplotlib.tests.test_figure',
14991498
'matplotlib.tests.test_font_manager',
15001499
'matplotlib.tests.test_gridspec',
15011500
'matplotlib.tests.test_image',

lib/matplotlib/tests/test_figure.py

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
from __future__ import (absolute_import, division, print_function,
22
unicode_literals)
33

4-
import six
54
from six.moves import xrange
65

7-
from nose.tools import assert_equal, assert_true
6+
from numpy.testing import assert_equal
87
from matplotlib import rcParams
98
from matplotlib.testing.decorators import image_comparison, cleanup
109
from matplotlib.axes import Axes
@@ -84,44 +83,42 @@ def test_gca():
8483
fig = plt.figure()
8584

8685
ax1 = fig.add_axes([0, 0, 1, 1])
87-
assert_true(fig.gca(projection='rectilinear') is ax1)
88-
assert_true(fig.gca() is ax1)
86+
assert fig.gca(projection='rectilinear') is ax1
87+
assert fig.gca() is ax1
8988

9089
ax2 = fig.add_subplot(121, projection='polar')
91-
assert_true(fig.gca() is ax2)
92-
assert_true(fig.gca(polar=True)is ax2)
90+
assert fig.gca() is ax2
91+
assert fig.gca(polar=True)is ax2
9392

9493
ax3 = fig.add_subplot(122)
95-
assert_true(fig.gca() is ax3)
94+
assert fig.gca() is ax3
9695

9796
# the final request for a polar axes will end up creating one
9897
# with a spec of 111.
9998
with warnings.catch_warnings(record=True) as w:
10099
warnings.simplefilter('always')
101100
# Changing the projection will throw a warning
102-
assert_true(fig.gca(polar=True) is not ax3)
101+
assert fig.gca(polar=True) is not ax3
103102
assert len(w) == 1
104-
assert_true(fig.gca(polar=True) is not ax2)
103+
assert fig.gca(polar=True) is not ax2
105104
assert_equal(fig.gca().get_geometry(), (1, 1, 1))
106105

107106
fig.sca(ax1)
108-
assert_true(fig.gca(projection='rectilinear') is ax1)
109-
assert_true(fig.gca() is ax1)
107+
assert fig.gca(projection='rectilinear') is ax1
108+
assert fig.gca() is ax1
110109

111110

112111
@image_comparison(baseline_images=['figure_suptitle'])
113112
def test_suptitle():
114-
fig = plt.figure()
115-
ax = fig.add_subplot(1, 1, 1)
113+
fig, _ = plt.subplots()
116114
fig.suptitle('hello', color='r')
117115
fig.suptitle('title', color='g', rotation='30')
118116

119117

120118
@cleanup
121119
def test_suptitle_fontproperties():
122120
from matplotlib.font_manager import FontProperties
123-
fig = plt.figure()
124-
ax = fig.add_subplot(1, 1, 1)
121+
fig, ax = plt.subplots()
125122
fps = FontProperties(size='large', weight='bold')
126123
txt = fig.suptitle('fontprops title', fontproperties=fps)
127124
assert_equal(txt.get_fontsize(), fps.get_size_in_points())
@@ -153,7 +150,7 @@ def test_too_many_figures():
153150
with warnings.catch_warnings(record=True) as w:
154151
warnings.simplefilter("always")
155152
for i in range(rcParams['figure.max_open_warning'] + 1):
156-
fig = plt.figure()
153+
plt.figure()
157154
assert len(w) == 1
158155

159156

@@ -184,7 +181,7 @@ def _as_mpl_axes(self):
184181
return MyAxes, {'myclass': self}
185182

186183
fig = plt.figure()
187-
ax = fig.add_subplot(1, 1, 1, projection=MyClass())
184+
fig.add_subplot(1, 1, 1, projection=MyClass())
188185
plt.close(fig)
189186

190187

@@ -230,8 +227,3 @@ def test_figaspect():
230227
assert h / w == 0.5
231228
w, h = plt.figaspect(np.zeros((2, 2)))
232229
assert h / w == 1
233-
234-
235-
if __name__ == "__main__":
236-
import nose
237-
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

0 commit comments

Comments
 (0)