From c0f71d6caced589731d5f276a469f4e4ebdb634b Mon Sep 17 00:00:00 2001 From: arw2019 Date: Mon, 12 Oct 2020 23:36:28 +0000 Subject: [PATCH] TST: examples from OP --- pandas/tests/series/test_constructors.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pandas/tests/series/test_constructors.py b/pandas/tests/series/test_constructors.py index a950ca78fc742..e20da0b891006 100644 --- a/pandas/tests/series/test_constructors.py +++ b/pandas/tests/series/test_constructors.py @@ -688,6 +688,13 @@ def test_constructor_coerce_float_valid(self, float_dtype): expected = Series([1, 2, 3.5]).astype(float_dtype) tm.assert_series_equal(s, expected) + def test_constructor_invalid_coerce_ints_with_float_nan(self, any_int_dtype): + # GH 22585 + + msg = "cannot convert float NaN to integer" + with pytest.raises(ValueError, match=msg): + pd.Series([1, 2, np.nan], dtype=any_int_dtype) + def test_constructor_dtype_no_cast(self): # see gh-1572 s = Series([1, 2, 3])