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

Skip to content

Commit 675424c

Browse files
committed
Convert test_[ab]* files to pytest.
1 parent 21c8157 commit 675424c

6 files changed

Lines changed: 18 additions & 51 deletions

File tree

lib/matplotlib/__init__.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,18 +1474,13 @@ def _jupyter_nbextension_paths():
14741474

14751475

14761476
default_test_modules = [
1477-
'matplotlib.tests.test_agg',
1478-
'matplotlib.tests.test_arrow_patches',
1479-
'matplotlib.tests.test_artist',
14801477
'matplotlib.tests.test_backend_bases',
14811478
'matplotlib.tests.test_backend_pdf',
14821479
'matplotlib.tests.test_backend_pgf',
14831480
'matplotlib.tests.test_backend_ps',
14841481
'matplotlib.tests.test_backend_qt4',
14851482
'matplotlib.tests.test_backend_qt5',
14861483
'matplotlib.tests.test_backend_svg',
1487-
'matplotlib.tests.test_basic',
1488-
'matplotlib.tests.test_bbox_tight',
14891484
'matplotlib.tests.test_coding_standards',
14901485
'matplotlib.tests.test_dviread',
14911486
'matplotlib.tests.test_figure',

lib/matplotlib/tests/test_agg.py

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

1111
import numpy as np
1212
from numpy.testing import assert_array_almost_equal
13-
14-
from nose.tools import assert_raises
13+
import pytest
1514

1615
from matplotlib.image import imread
1716
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
@@ -297,9 +296,5 @@ def process_image(self, padded_src, dpi):
297296
def test_too_large_image():
298297
fig = plt.figure(figsize=(300, 1000))
299298
buff = io.BytesIO()
300-
assert_raises(ValueError, fig.savefig, buff)
301-
302-
303-
if __name__ == "__main__":
304-
import nose
305-
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)
299+
with pytest.raises(ValueError):
300+
fig.savefig(buff)

lib/matplotlib/tests/test_arrow_patches.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,3 @@ def test_fancyarrow_dash():
121121
color='k')
122122
ax.add_patch(e)
123123
ax.add_patch(e2)
124-
125-
126-
if __name__ == '__main__':
127-
import nose
128-
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

lib/matplotlib/tests/test_artist.py

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import matplotlib as mpl
1818
from matplotlib.testing.decorators import image_comparison, cleanup
1919

20-
from nose.tools import (assert_true, assert_false)
21-
2220

2321
@cleanup
2422
def test_patch_transform_of_none():
@@ -184,28 +182,28 @@ def test_remove():
184182
im = ax.imshow(np.arange(36).reshape(6, 6))
185183
ln, = ax.plot(range(5))
186184

187-
assert_true(fig.stale)
188-
assert_true(ax.stale)
185+
assert fig.stale
186+
assert ax.stale
189187

190188
fig.canvas.draw()
191-
assert_false(fig.stale)
192-
assert_false(ax.stale)
193-
assert_false(ln.stale)
189+
assert not fig.stale
190+
assert not ax.stale
191+
assert not ln.stale
194192

195-
assert_true(im in ax.mouseover_set)
196-
assert_true(ln not in ax.mouseover_set)
197-
assert_true(im.axes is ax)
193+
assert im in ax.mouseover_set
194+
assert ln not in ax.mouseover_set
195+
assert im.axes is ax
198196

199197
im.remove()
200198
ln.remove()
201199

202200
for art in [im, ln]:
203-
assert_true(art.axes is None)
204-
assert_true(art.figure is None)
201+
assert art.axes is None
202+
assert art.figure is None
205203

206-
assert_true(im not in ax.mouseover_set)
207-
assert_true(fig.stale)
208-
assert_true(ax.stale)
204+
assert im not in ax.mouseover_set
205+
assert fig.stale
206+
assert ax.stale
209207

210208

211209
@image_comparison(baseline_images=["default_edges"], remove_text=True,
@@ -254,8 +252,3 @@ def test_setp():
254252
sio = io.StringIO()
255253
plt.setp(lines1, 'zorder', file=sio)
256254
assert sio.getvalue() == ' zorder: any number \n'
257-
258-
259-
if __name__ == '__main__':
260-
import nose
261-
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

lib/matplotlib/tests/test_basic.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
import warnings
88

9-
from nose.tools import assert_equal
10-
119
from ..testing.decorators import knownfailureif, skipif
1210

1311

@@ -19,13 +17,13 @@ def setup_module():
1917

2018

2119
def test_simple():
22-
assert_equal(1 + 1, 2)
20+
assert 1 + 1 == 2
2321

2422

2523
@knownfailureif(True)
2624
def test_simple_knownfail():
2725
# Test the known fail mechanism.
28-
assert_equal(1 + 1, 3)
26+
assert 1 + 1 == 3
2927

3028

3129
@skipif(True, reason="skipif decorator test with bool condition passed")
@@ -91,8 +89,3 @@ def test_override_builtins():
9189
overridden = True
9290

9391
assert not overridden
94-
95-
96-
if __name__ == '__main__':
97-
import nose
98-
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

lib/matplotlib/tests/test_bbox_tight.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,3 @@ def test_bbox_inches_tight_raster():
9393
fig = plt.figure()
9494
ax = fig.add_subplot(111)
9595
ax.plot([1.0, 2.0], rasterized=True)
96-
97-
if __name__ == '__main__':
98-
import nose
99-
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

0 commit comments

Comments
 (0)