MCPcopy
hub / github.com/pandas-dev/pandas / test_fullmatch_lookarounds

Function test_fullmatch_lookarounds

pandas/tests/strings/test_find_replace.py:1422–1439  ·  view source on GitHub ↗
(any_string_dtype, pat)

Source from the content-addressed store, hash-verified

1420 [(r"a(?=b)"), (r"(?<=a)b"), (r"a(?!b)"), (r"(?<!b)a"), ("ab")],
1421)
1422def test_fullmatch_lookarounds(any_string_dtype, pat):
1423 # https://github.com/pandas-dev/pandas/issues/60833
1424 # Note: By definition, any match with a lookaround is not a full match.
1425 if any_string_dtype == "object":
1426 expected_dtype, null_result = "object", None
1427 elif any_string_dtype == "str":
1428 expected_dtype, null_result = "bool", False
1429 elif any_string_dtype == "string":
1430 expected_dtype, null_result = "boolean", pd.NA
1431 else:
1432 raise ValueError(f"Unrecognized dtype: {any_string_dtype}")
1433 ser = Series(["aa", "ab", "ba", "bb", None], dtype=any_string_dtype)
1434 result = ser.str.fullmatch(pat)
1435 expected = Series(
1436 [False, True if pat == "ab" else False, False, False, null_result],
1437 dtype=expected_dtype,
1438 )
1439 tm.assert_series_equal(result, expected)
1440
1441
1442def test_fullmatch_end_of_string(any_string_dtype):

Callers

nothing calls this directly

Calls 2

SeriesClass · 0.90
fullmatchMethod · 0.80

Tested by

no test coverage detected