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

Skip to content

Commit a660aa6

Browse files
committed
Improved syntax of exception handling in tests
1 parent 88ee7bf commit a660aa6

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

lib/matplotlib/tests/test_triangulation.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,18 +1124,17 @@ def test_tricontour_non_finite_z():
11241124
triang = mtri.Triangulation(x, y)
11251125
plt.figure()
11261126

1127-
with pytest.raises(ValueError) as excinfo:
1127+
with pytest.raises(ValueError, match='z array cannot contain non-finite ' +
1128+
'values'):
11281129
plt.tricontourf(triang, [0, 1, 2, np.inf])
1129-
excinfo.match(r'z array cannot contain non-finite values')
11301130

1131-
with pytest.raises(ValueError) as excinfo:
1131+
with pytest.raises(ValueError, match='z array cannot contain non-finite ' +
1132+
'values'):
11321133
plt.tricontourf(triang, [0, 1, 2, -np.inf])
1133-
excinfo.match(r'z array cannot contain non-finite values')
11341134

1135-
with pytest.raises(ValueError) as excinfo:
1135+
with pytest.raises(ValueError, match='z array cannot contain non-finite ' +
1136+
'values'):
11361137
plt.tricontourf(triang, [0, 1, 2, np.nan])
1137-
excinfo.match(r'z array cannot contain non-finite values')
11381138

1139-
with pytest.raises(ValueError) as excinfo:
1139+
with pytest.raises(ValueError, match='z cannot be a masked array'):
11401140
plt.tricontourf(triang, np.ma.array([0, 1, 2, 3], mask=[1, 0, 0, 0]))
1141-
excinfo.match(r'z cannot be a masked array')

0 commit comments

Comments
 (0)