Skip to content

Commit f4f75ab

Browse files
committed
test: add str.isascii testcase
1 parent d489885 commit f4f75ab

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

pandas/tests/strings/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
"get_dummies",
6969
"isalnum",
7070
"isalpha",
71+
"isascii",
7172
"isdecimal",
7273
"isdigit",
7374
"islower",
@@ -97,7 +98,6 @@
9798
)
9899
ids, _, _ = zip(*_any_string_method) # use method name as fixture-id
99100
missing_methods = {f for f in dir(StringMethods) if not f.startswith("_")} - set(ids)
100-
101101
# test that the above list captures all methods of StringMethods
102102
assert not missing_methods
103103

pandas/tests/strings/test_strings.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,19 @@ def test_ismethods(method, expected, any_string_dtype):
217217
assert list(result) == expected
218218

219219

220+
def test_isascii(any_string_dtype):
221+
ser = Series(
222+
["a", "bb", "123", "あ", "\n", "", " ", "¼"],
223+
dtype=any_string_dtype,
224+
)
225+
expected_dtype = "bool" if any_string_dtype in object_pyarrow_numpy else "boolean"
226+
result = ser.str.isascii()
227+
expected = Series(
228+
[True, True, True, False, True, True, True, False], dtype=expected_dtype
229+
)
230+
tm.assert_series_equal(result, expected)
231+
232+
220233
@pytest.mark.parametrize(
221234
"method, expected",
222235
[

0 commit comments

Comments
 (0)