Skip to content

Commit 771e2f6

Browse files
author
Rohan Jain
committed
improve test cases
1 parent 52a6f52 commit 771e2f6

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

pandas/tests/extension/test_arrow.py

+21
Original file line numberDiff line numberDiff line change
@@ -1962,6 +1962,27 @@ def test_str_find_negative_start_negative_end():
19621962
tm.assert_series_equal(result, expected)
19631963

19641964

1965+
def test_str_find_large_start():
1966+
# GH 56791
1967+
ser = pd.Series(["abcdefg", None], dtype=ArrowDtype(pa.string()))
1968+
if pa_version_under13p0:
1969+
# https://github.com/apache/arrow/issues/36311
1970+
with pytest.raises(pa.lib.ArrowInvalid, match="Negative buffer resize"):
1971+
ser.str.find(sub="d", start=16)
1972+
else:
1973+
result = ser.str.find(sub="d", start=16)
1974+
expected = pd.Series([-1, None], dtype=ArrowDtype(pa.int64()))
1975+
tm.assert_series_equal(result, expected)
1976+
1977+
1978+
def test_str_find_negative_start_negative_end_no_match():
1979+
# GH 56791
1980+
ser = pd.Series(["abcdefg", None], dtype=ArrowDtype(pa.string()))
1981+
result = ser.str.find(sub="d", start=-3, end=-6)
1982+
expected = pd.Series([-1, None], dtype=ArrowDtype(pa.int64()))
1983+
tm.assert_series_equal(result, expected)
1984+
1985+
19651986
@pytest.mark.parametrize(
19661987
"i, exp",
19671988
[

0 commit comments

Comments
 (0)