diff --git a/pandas/tests/arrays/test_array.py b/pandas/tests/arrays/test_array.py index 61d56df485ab1..958ccec930f0e 100644 --- a/pandas/tests/arrays/test_array.py +++ b/pandas/tests/arrays/test_array.py @@ -309,6 +309,14 @@ def test_scalar_raises(): pd.array(1) +def test_bounds_check(): + # GH21796 + with pytest.raises( + TypeError, match=r"cannot safely cast non-equivalent int(32|64) to uint16" + ): + pd.array([-1, 2, 3], dtype="UInt16") + + # --------------------------------------------------------------------------- # A couple dummy classes to ensure that Series and Indexes are unboxed before # getting to the EA classes.