10000 Convert remaining test_t* files to pytest. · matplotlib/matplotlib@a498e24 · GitHub
[go: up one dir, main page]

Skip to content

Commit a498e24

Browse files
committed
Convert remaining test_t* files to pytest.
1 parent 1be56c8 commit a498e24

File tree

4 files changed

+28
-32
lines changed

4 files changed

+28
-32
lines changed

lib/matplotlib/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,11 +1512,8 @@ def _jupyter_nbextension_paths():
15121512
'matplotlib.tests.test_streamplot',
15131513
'matplotlib.tests.test_style',
15141514
'matplotlib.tests.test_subplots',
1515-
'matplotlib.tests.test_table',
15161515
'matplotlib.tests.test_text',
15171516
'matplotlib.tests.test_texmanager',
1518-
'matplotlib.tests.test_tightlayout',
1519-
'matplotlib.tests.test_triangulation',
15201517
'matplotlib.tests.test_type1font',
15211518
'matplotlib.tests.test_ttconv',
15221519
'matplotlib.tests.test_units',

lib/matplotlib/tests/test_table.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
from matplotlib.table import CustomCell
1111
from matplotlib.path import Path
12-
from nose.tools import assert_equal
1312

1413

1514
@cleanup
@@ -127,7 +126,7 @@ def test_customcell():
127126
for t, c in zip(types, codes):
128127
cell = CustomCell((0, 0), visible_edges=t, width=1, height=1)
129128
code = tuple(s for _, s in cell.get_path().iter_segments())
130-
assert_equal(c, code)
129+
assert c == code
131130

132131

133132
@image_comparison(baseline_images=['table_auto_column'],

lib/matplotlib/tests/test_tightlayout.py

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

99
from matplotlib.testing.decorators import image_comparison, knownfailureif
1010
import matplotlib.pyplot as plt
11-
from nose.tools import assert_raises
12-
from numpy.testing import assert_array_equal
1311
from matplotlib.offsetbox import AnchoredOffsetbox, DrawingArea
1412
from matplotlib.patches import Rectangle
1513

lib/matplotlib/tests/test_triangulation.py

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import numpy as np
77
import matplotlib.pyplot as plt
88
import matplotlib.tri as mtri
9-
from nose.tools import assert_equal, assert_raises, assert_true, assert_false
9+
import pytest
1010
from numpy.testing import assert_array_equal, assert_array_almost_equal,\
1111
assert_array_less
1212
import numpy.ma.testutils as matest
@@ -39,14 +39,14 @@ def test_delaunay():
3939
assert_array_almost_equal(triang.y, y)
4040

4141
# Triangles - integers.
42-
assert_equal(len(triang.triangles), ntriangles)
43-
assert_equal(np.min(triang.triangles), 0)
44-
assert_equal(np.max(triang.triangles), npoints-1)
42+
assert len(triang.triangles) == ntriangles
43+
assert np.min(triang.triangles) == 0
44+
assert np.max(triang.triangles) == npoints-1
4545

4646
# Edges - integers.
47-
assert_equal(len(triang.edges), nedges)
48-
assert_equal(np.min(triang.edges), 0)
49-
assert_equal(np.max(triang.edges), npoints-1)
47+
assert len(triang.edges) == nedges
48+
assert np.min(triang.edges) == 0
49+
assert np.max(triang.edges) == npoints-1
5050

5151
# Neighbors - integers.
5252
# Check that neighbors calculated by C++ triangulation class are the same
@@ -86,7 +86,8 @@ def test_delaunay_points_in_line():
8686
# that delaunay code fails gracefully.
8787
x = np.linspace(0.0, 10.0, 11)
8888
y = np.linspace(0.0, 10.0, 11)
89-
assert_raises(RuntimeError, mtri.Triangulation, x, y)
89+
with pytest.raises(RuntimeError):
90+
mtri.Triangulation(x, y)
9091

9192
# Add an extra point not on the line and the triangulation is OK.
9293
x = np.append(x, 2.0)
@@ -96,16 +97,21 @@ def test_delaunay_points_in_line():
9697

9798
def test_delaunay_insufficient_points():
9899
# Triangulation should raise a ValueError if passed less than 3 points.
99-
assert_raises(ValueError, mtri.Triangulation, [], [])
100-
assert_raises(ValueError, mtri.Triangulation, [1], [5])
101-
assert_raises(ValueError, mtri.Triangulation, [1, 2], [5, 6])
100+
with pytest.raises(ValueError):
101+
mtri.Triangulation([], [])
102+
with pytest.raises(ValueError):
103+
mtri.Triangulation([1], [5])
104+
with pytest.raises(ValueError):
105+
mtri.Triangulation([1, 2], [5, 6])
102106

103107
# Triangulation should also raise a ValueError if passed duplicate points
104108
# such that there are less than 3 unique points.
105-
assert_raises(ValueError, mtri.Triangulation, [1, 2, 1], [5, 6, 5])
106-
assert_raises(ValueError, mtri.Triangulation, [1, 2, 2], [5, 6, 6])
107-
assert_raises(ValueError, mtri.Triangulation, [1, 1, 1, 2, 1, 2],
108-
[5, 5, 5, 6, 5, 6])
109+
with pytest.raises(ValueError):
110+
mtri.Triangulation([1, 2, 1], [5, 6, 5])
111+
with pytest.raises(ValueError):
112+
mtri.Triangulation([1, 2, 2], [5, 6, 6])
113+
with pytest.raises(ValueError):
114+
mtri.Triangulation([1, 1, 1, 2, 1, 2], [5, 5, 5, 6, 5, 6])
109115

110116

111117
def test_delaunay_robust():
@@ -149,7 +155,7 @@ def tris_contain_point(triang, xy):
149155
# overlapping triangles; qhull is OK.
150156
triang = mtri.Triangulation(tri_points[:, 0], tri_points[:, 1])
151157
for test_point in test_points:
152-
assert_equal(tris_contain_point(triang, test_point), 1)
158+
assert tris_contain_point(triang, test_point) == 1
153159

154160
# If ignore the first point of tri_points, matplotlib.delaunay throws a
155161
# KeyError when calculating the convex hull; qhull is OK.
@@ -283,7 +289,7 @@ def test_trifinder():
283289
assert_array_equal(tris, [-1, 0, 1, -1])
284290

285291
triang.set_mask([1, 0])
286-
assert_equal(trifinder, triang.get_trifinder())
292+
assert trifinder == triang.get_trifinder()
287293
tris = trifinder(xs, ys)
288294
assert_array_equal(tris, [-1, -1, 1, -1])
289295

@@ -971,10 +977,10 @@ def test_trirefiner_fortran_contiguous_triangles():
971977
# github issue 4180. Test requires two arrays of triangles that are
972978
# identical except that one is C-contiguous and one is fortran-contiguous.
973979
triangles1 = np.array([[2, 0, 3], [2, 1, 0]])
974-
assert_false(np.isfortran(triangles1))
980+
assert not np.isfortran(triangles1)
975981

976982
triangles2 = np.array(triangles1, copy=True, order='F')
977-
assert_true(np.isfortran(triangles2))
983+
assert np.isfortran(triangles2)
978984

979985
x = np.array([0.39, 0.59, 0.43, 0.32])
980986
y = np.array([33.99, 34.01, 34.19, 34.18])
@@ -1033,9 +1039,5 @@ def test_tricontourf_decreasing_levels():
10331039
y = [0.0, 0.0, 1.0]
10341040
z = [0.2, 0.4, 0.6]
10351041
plt.figure()
1036-
assert_raises(ValueError, plt.tricontourf, x, y, z, [1.0, 0.0])
1037-
1038-
1039-
if __name__ == '__main__':
1040-
import nose
1041-
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)
1042+
with pytest.raises(ValueError):
1043+
plt.tricontourf(x, y, z, [1.0, 0.0])

0 commit comments

Comments
 (0)
0