Skip to content

Commit 4aaf8dc

Browse files
committed
Tests for errors extended and moved to own function
1 parent 8c6ff7a commit 4aaf8dc

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pandas/tests/series/test_missing.py

+17
Original file line numberDiff line numberDiff line change
@@ -1277,10 +1277,27 @@ def test_interp_max_gap(self):
12771277
result = s.interpolate(method='linear', max_gap=2, limit_area='inside')
12781278
assert_series_equal(result, excpected)
12791279

1280+
def test_interp_max_gap_errors(self):
1281+
s = Series([
1282+
np.nan,
1283+
1., np.nan,
1284+
2., np.nan, np.nan,
1285+
5., np.nan, np.nan, np.nan,
1286+
-1., np.nan, np.nan
1287+
])
1288+
12801289
with pytest.raises(ValueError,
12811290
match='max_gap cannot be used together with limit'):
12821291
s.interpolate(method='linear', max_gap=2, limit=3)
12831292

1293+
with pytest.raises(ValueError,
1294+
match='max_gap must be an integer'):
1295+
s.interpolate(method='linear', max_gap='foo')
1296+
1297+
with pytest.raises(ValueError,
1298+
match='max_gap must be greater than 0'):
1299+
s.interpolate(method='linear', max_gap=0)
1300+
12841301
def test_interp_limit_before_ends(self):
12851302
# These test are for issue #11115 -- limit ends properly.
12861303
s = Series([np.nan, np.nan, 5, 7, np.nan, np.nan])

0 commit comments

Comments
 (0)