Skip to content

Commit c0c778b

Browse files
authored
TST: Add test for exceptional behavior when calling view() on BaseStringArray (#60799)
* add test for when str array raises type error * fix formatting: ruff-format * moved test to tests/arrays/string_/test_string.py file
1 parent e36b000 commit c0c778b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pandas/tests/arrays/string_/test_string.py

+6
Original file line numberDiff line numberDiff line change
@@ -758,3 +758,9 @@ def test_tolist(dtype):
758758
result = arr.tolist()
759759
expected = vals
760760
tm.assert_equal(result, expected)
761+
762+
763+
def test_string_array_view_type_error():
764+
arr = pd.array(["a", "b", "c"], dtype="string")
765+
with pytest.raises(TypeError, match="Cannot change data-type for string array."):
766+
arr.view("i8")

0 commit comments

Comments
 (0)