Skip to content

Commit

Permalink
TST: Add test for exceptional behavior when calling view() on `Base…
Browse files Browse the repository at this point in the history
…StringArray` (#60799)

* add test for when str array raises type error

* fix formatting: ruff-format

* moved test to tests/arrays/string_/test_string.py file
  • Loading branch information
MattePalte authored Jan 27, 2025
1 parent e36b000 commit c0c778b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pandas/tests/arrays/string_/test_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,3 +758,9 @@ def test_tolist(dtype):
result = arr.tolist()
expected = vals
tm.assert_equal(result, expected)


def test_string_array_view_type_error():
arr = pd.array(["a", "b", "c"], dtype="string")
with pytest.raises(TypeError, match="Cannot change data-type for string array."):
arr.view("i8")

0 comments on commit c0c778b

Please sign in to comment.