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

Skip to content

Commit 9738c65

Browse files
committed
Convert test_s* to pytest.
1 parent 21c8157 commit 9738c65

9 files changed

Lines changed: 23 additions & 62 deletions

File tree

lib/matplotlib/__init__.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,14 +1502,6 @@ def _jupyter_nbextension_paths():
15021502
'matplotlib.tests.test_pickle',
15031503
'matplotlib.tests.test_png',
15041504
'matplotlib.tests.test_quiver',
1505-
'matplotlib.tests.test_sankey',
1506-
'matplotlib.tests.test_scale',
1507-
'matplotlib.tests.test_simplification',
1508-
'matplotlib.tests.test_skew',
1509-
'matplotlib.tests.test_spines',
1510-
'matplotlib.tests.test_streamplot',
1511-
'matplotlib.tests.test_style',
1512-
'matplotlib.tests.test_subplots',
15131505
'matplotlib.tests.test_text',
15141506
'matplotlib.tests.test_texmanager',
15151507
'matplotlib.tests.test_type1font',

lib/matplotlib/tests/test_sankey.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,3 @@ def test_sankey():
1212
# lets just create a sankey instance and check the code runs
1313
sankey = Sankey()
1414
sankey.add()
15-
16-
17-
if __name__ == '__main__':
18-
import nose
19-
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

lib/matplotlib/tests/test_scale.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,3 @@ def test_log_scatter():
4646

4747
buf = io.BytesIO()
4848
fig.savefig(buf, format='svg')
49-
50-
51-
if __name__ == '__main__':
52-
import nose
53-
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

lib/matplotlib/tests/test_simplification.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from matplotlib import patches, path, transforms
1212

13-
from nose.tools import raises
13+
import pytest
1414
import io
1515

1616
nan = np.nan
@@ -159,7 +159,6 @@ def test_start_with_moveto():
159159
assert segs[0][1] == Path.MOVETO
160160

161161
@cleanup
162-
@raises(OverflowError)
163162
def test_throw_rendering_complexity_exceeded():
164163
plt.rcParams['path.simplify'] = False
165164
xx = np.arange(200000)
@@ -168,10 +167,9 @@ def test_throw_rendering_complexity_exceeded():
168167
fig = plt.figure()
169168
ax = fig.add_subplot(111)
170169
ax.plot(xx, yy)
171-
try:
170+
with pytest.raises(OverflowError):
172171
fig.savefig(io.BytesIO())
173-
finally:
174-
plt.rcParams['path.simplify'] = True
172+
175173

176174
@image_comparison(baseline_images=['clipper_edge'], remove_text=True)
177175
def test_clipper():
@@ -224,8 +222,3 @@ def test_clipping_full():
224222
simplified = list(p.iter_segments(clip=[0, 0, 100, 100]))
225223
assert ([(list(x), y) for x, y in simplified] ==
226224
[([50, 40], 1)])
227-
228-
229-
if __name__=='__main__':
230-
import nose
231-
nose.runmodule(argv=['-s','--with-doctest'], exit=False)

lib/matplotlib/tests/test_skew.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,3 @@ def test_skew_rectange():
210210
alpha=0.5, facecolor='coral'))
211211

212212
plt.subplots_adjust(wspace=0, left=0, right=1, bottom=0)
213-
214-
if __name__ == '__main__':
215-
import nose
216-
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

lib/matplotlib/tests/test_spines.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
unicode_literals)
33

44
import numpy as np
5-
from nose.tools import assert_true, assert_less
65
import six
76

87
import matplotlib
@@ -71,11 +70,11 @@ def test_label_without_ticks():
7170
spine = ax.spines['left']
7271
spinebbox = spine.get_transform().transform_path(
7372
spine.get_path()).get_extents()
74-
assert_less(ax.yaxis.label.get_position()[0], spinebbox.xmin,
75-
"Y-Axis label not left of the spine")
73+
assert ax.yaxis.label.get_position()[0] < spinebbox.xmin, \
74+
"Y-Axis label not left of the spine"
7675

7776
spine = ax.spines['bottom']
7877
spinebbox = spine.get_transform().transform_path(
7978
spine.get_path()).get_extents()
80-
assert_less(ax.xaxis.label.get_position()[1], spinebbox.ymin,
81-
"X-Axis label not below the spine")
79+
assert ax.xaxis.label.get_position()[1] < spinebbox.ymin, \
80+
"X-Axis label not below the spine"

lib/matplotlib/tests/test_streamplot.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,3 @@ def test_streamplot_limits():
9595
# datalim.
9696
assert_array_almost_equal(ax.dataLim.bounds, (20, 30, 15, 6),
9797
decimal=1)
98-
99-
100-
if __name__=='__main__':
101-
import nose
102-
nose.runmodule()

lib/matplotlib/tests/test_style.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
from collections import OrderedDict
99
from contextlib import contextmanager
1010

11-
from nose.tools import assert_raises
12-
from nose.plugins.attrib import attr
11+
import pytest
1312

1413
import matplotlib as mpl
1514
from matplotlib import style
@@ -70,7 +69,7 @@ def test_use():
7069
assert mpl.rcParams[PARAM] == VALUE
7170

7271

73-
@attr('network')
72+
@pytest.mark.network
7473
def test_use_url():
7574
with temp_style('test', DUMMY_SETTINGS):
7675
with style.context('https://gist.github.com/adrn/6590261/raw'):
@@ -140,10 +139,7 @@ def test_context_with_badparam():
140139
with style.context({PARAM: other_value}):
141140
assert mpl.rcParams[PARAM] == other_value
142141
x = style.context([d])
143-
assert_raises(KeyError, x.__enter__)
142+
with pytest.raises(KeyError):
143+
with x:
144+
pass
144145
assert mpl.rcParams[PARAM] == other_value
145-
146-
147-
if __name__ == '__main__':
148-
from numpy import testing
149-
testing.run_module_suite()

lib/matplotlib/tests/test_subplots.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import matplotlib.pyplot as plt
1010
from matplotlib.testing.decorators import image_comparison, cleanup
1111

12-
from nose.tools import assert_raises
12+
import pytest
1313

1414

1515
def check_shared(axs, x_shared, y_shared):
@@ -105,17 +105,22 @@ def test_shared():
105105
@cleanup
106106
def test_exceptions():
107107
# TODO should this test more options?
108-
assert_raises(ValueError, plt.subplots, 2, 2, sharex='blah')
109-
assert_raises(ValueError, plt.subplots, 2, 2, sharey='blah')
108+
with pytest.raises(ValueError):
109+
plt.subplots(2, 2, sharex='blah')
110+
with pytest.raises(ValueError):
111+
plt.subplots(2, 2, sharey='blah')
110112
# We filter warnings in this test which are genuine since
111113
# the point of this test is to ensure that this raises.
112114
with warnings.catch_warnings():
113115
warnings.filterwarnings('ignore',
114116
message='.*sharex\ argument\ to\ subplots',
115117
category=UserWarning)
116-
assert_raises(ValueError, plt.subplots, 2, 2, -1)
117-
assert_raises(ValueError, plt.subplots, 2, 2, 0)
118-
assert_raises(ValueError, plt.subplots, 2, 2, 5)
118+
with pytest.raises(ValueError):
119+
plt.subplots(2, 2, -1)
120+
with pytest.raises(ValueError):
121+
plt.subplots(2, 2, 0)
122+
with pytest.raises(ValueError):
123+
plt.subplots(2, 2, 5)
119124

120125

121126
@image_comparison(baseline_images=['subplots_offset_text'], remove_text=False)
@@ -127,8 +132,3 @@ def test_subplots_offsettext():
127132
axes[1, 0].plot(x, x)
128133
axes[0, 1].plot(y, x)
129134
axes[1, 1].plot(y, x)
130-
131-
132-
if __name__ == "__main__":
133-
import nose
134-
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

0 commit comments

Comments
 (0)