8000 Merge pull request #7897 from NelleV/pytest_f_modules · adrn/matplotlib@6bbf92c · GitHub
[go: up one dir, main page]

Skip to content

Commit 6bbf92c

Browse files
authored
Merge pull request matplotlib#7897 from NelleV/pytest_f_modules
MAINT moved all remaining "f" modules to pytest
2 parents 0b1d896 + 3a96dbc commit 6bbf92c

File tree

2 files changed

+15
-26
lines changed

2 files changed

+15
-26
lines changed

lib/matplotlib/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1476,7 +1476,6 @@ def _jupyter_nbextension_paths():
14761476
default_test_modules = [
14771477
'matplotlib.tests.test_coding_standards',
14781478
'matplotlib.tests.test_dviread',
1479-
'matplotlib.tests.test_figure',
14801479
'matplotlib.tests.test_font_manager',
14811480
'matplotlib.tests.test_gridspec',
14821481
'matplotlib.tests.test_image',

lib/matplotlib/tests/test_figure.py

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

4-
import six
5-
from six.moves import xrange
8000 6-
7-
from nose.tools import assert_equal, assert_true
4+
from numpy.testing import assert_equal
85
from matplotlib import rcParams
96
from matplotlib.testing.decorators import image_comparison, cleanup
107
from matplotlib.axes import Axes
@@ -58,7 +55,7 @@ def test_figure():
5855
fig = plt.figure('today')
5956
ax = fig.add_subplot(111)
6057
ax.set_title(fig.get_label())
61-
ax.plot(list(xrange(5)))
58+
ax.plot(np.arange(5))
6259
# plot red line in a different figure.
6360
plt.figure('tomorrow')
6461
plt.plot([0, 1], [1, 0], 'r')
@@ -84,44 +81,42 @@ def test_gca():
8481
fig = plt.figure()
8582

8683
ax1 = fig.add_axes([0, 0, 1, 1])
87-
assert_true(fig.gca(projection='rectilinear') is ax1)
88-
assert_true(fig.gca() is ax1)
84+
assert fig.gca(projection='rectilinear') is ax1
85+
assert fig.gca() is ax1
8986

9087
ax2 = fig.add_subplot(121, projection='polar')
91-
assert_true(fig.gca() is ax2)
92-
assert_true(fig.gca(polar=True)is ax2)
88+
assert fig.gca() is ax2
89+
assert fig.gca(polar=True)is ax2
9390

9491
ax3 = fig.add_subplot(122)
95-
assert_true(fig.gca() is ax3)
92+
assert fig.gca() is ax3
9693

9794
# the final request for a polar axes will end up creating one
9895
# with a spec of 111.
9996
with warnings.catch_warnings(record=True) as w:
10097
warnings.simplefilter('always')
10198
# Changing the projection will throw a warning
102-
assert_true(fig.gca(polar=True) is not ax3)
99+
assert fig.gca(polar=True) is not ax3
103100
assert len(w) == 1
104-
assert_true(fig.gca(polar=True) is not ax2)
101+
assert fig.gca(polar=True) is not ax2
105102
assert_equal(fig.gca().get_geometry(), (1, 1, 1))
106103

107104
fig.sca(ax1)
108-
assert_true(fig.gca(projection='rectilinear') is ax1)
109-
assert_true(fig.gca() is ax1)
105+
assert fig.gca(projection='rectilinear') is ax1
106+
assert fig.gca() is ax1
110107

111108

112109
@image_comparison(baseline_images=['figure_suptitle'])
113110
def test_suptitle():
114-
fig = plt.figure()
115-
ax = fig.add_subplot(1, 1, 1)
111+
fig, _ = plt.subplots()
116112
fig.suptitle('hello', color='r')
117113
fig.suptitle('title', color='g', rotation='30')
118114

119115

120116
@cleanup
121117
def test_suptitle_fontproperties():
122118
from matplotlib.font_manager import FontProperties
123-
fig = plt.figure()
124-
ax = fig.add_subplot(1, 1, 1)
119+
fig, ax = plt.subplots()
125120
fps = FontProperties(size='large', weight='bold')
126121
txt = fig.suptitle('fontprops title', fontproperties=fps)
127122
assert_equal(txt.get_fontsize(), fps.get_size_in_points())
@@ -153,7 +148,7 @@ def test_too_many_figures():
153148
with warnings.catch_warnings(record=True) as w:
154149
warnings.simplefilter("always")
155150
for i in range(rcParams['figure.max_open_warning'] + 1):
156-
fig = plt.figure()
151+
plt.figure()
157152
assert len(w) == 1
158153

159154

@@ -184,7 +179,7 @@ def _as_mpl_axes(self):
184179
return MyAxes, {'myclass': self}
185180

186181
fig = plt.figure()
187-
ax = fig.add_subplot(1, 1, 1, projection=MyClass())
182+
fig.add_subplot(1, 1, 1, projection=MyClass())
188183
plt.close(fig)
189184

190185

@@ -230,8 +225,3 @@ def test_figaspect():
230225
assert h / w == 0.5
231226
w, h = plt.figaspect(np.zeros((2, 2)))
232227
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)
0