From 1d25bbe816925b54da39c261e3eaa17621dc1e3f Mon Sep 17 00:00:00 2001 From: Alex Watt Date: Sat, 30 Mar 2019 18:56:05 -0400 Subject: [PATCH 1/2] TST: Add regression test for #23986 --- pandas/tests/indexes/datetimes/test_construction.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pandas/tests/indexes/datetimes/test_construction.py b/pandas/tests/indexes/datetimes/test_construction.py index 6a13836be0dfa..f8d546c39a701 100644 --- a/pandas/tests/indexes/datetimes/test_construction.py +++ b/pandas/tests/indexes/datetimes/test_construction.py @@ -535,6 +535,12 @@ def test_constructor_dtype(self): result = DatetimeIndex(idx, dtype='datetime64[ns, US/Eastern]') tm.assert_index_equal(idx, result) + @pytest.mark.parametrize('dtype', [object, np.int32, np.int64]) + def test_constructor_invalid_dtype(self, dtype): + # GH 23986 + with pytest.raises(ValueError): + DatetimeIndex([1, 2], dtype=dtype) + def test_constructor_name(self): idx = date_range(start='2000-01-01', periods=1, freq='A', name='TEST') From ba004c9c1ab32744092539907da63f607a61414b Mon Sep 17 00:00:00 2001 From: Alex Watt Date: Sat, 30 Mar 2019 22:35:13 -0400 Subject: [PATCH 2/2] Update test name per convention --- pandas/tests/indexes/datetimes/test_construction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/indexes/datetimes/test_construction.py b/pandas/tests/indexes/datetimes/test_construction.py index f8d546c39a701..fa9d5b858a092 100644 --- a/pandas/tests/indexes/datetimes/test_construction.py +++ b/pandas/tests/indexes/datetimes/test_construction.py @@ -536,7 +536,7 @@ def test_constructor_dtype(self): tm.assert_index_equal(idx, result) @pytest.mark.parametrize('dtype', [object, np.int32, np.int64]) - def test_constructor_invalid_dtype(self, dtype): + def test_constructor_invalid_dtype_raises(self, dtype): # GH 23986 with pytest.raises(ValueError): DatetimeIndex([1, 2], dtype=dtype)