From 612ce0c7ce8cf0dac9a00df7d49f8667e893f2d6 Mon Sep 17 00:00:00 2001 From: Thomas Dickson Date: Sun, 27 Jun 2021 16:32:39 +0000 Subject: [PATCH 1/2] TST IntegerArray bounds error closing GH21796 --- pandas/tests/arrays/test_array.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pandas/tests/arrays/test_array.py b/pandas/tests/arrays/test_array.py index 61d56df485ab1..608fc1d9c56c3 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="cannot safely cast non-equivalent int64 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. From 5c250a243afb3a463566c7c478aa6e6f1028c3e1 Mon Sep 17 00:00:00 2001 From: Thomas Dickson Date: Sun, 27 Jun 2021 18:05:35 +0000 Subject: [PATCH 2/2] handle 32 and 64 options in error msg solving #21796 --- pandas/tests/arrays/test_array.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/arrays/test_array.py b/pandas/tests/arrays/test_array.py index 608fc1d9c56c3..958ccec930f0e 100644 --- a/pandas/tests/arrays/test_array.py +++ b/pandas/tests/arrays/test_array.py @@ -312,7 +312,7 @@ def test_scalar_raises(): def test_bounds_check(): # GH21796 with pytest.raises( - TypeError, match="cannot safely cast non-equivalent int64 to uint16" + TypeError, match=r"cannot safely cast non-equivalent int(32|64) to uint16" ): pd.array([-1, 2, 3], dtype="UInt16")