@@ -433,31 +433,51 @@ def test_add_iadd(self):
433433 tm .assert_index_equal (rng , expected )
434434
435435 idx = DatetimeIndex (['2011-01-01' , '2011-01-02' ])
436- msg = "cannot add a datelike to a DatetimeIndex "
436+ msg = "cannot add DatetimeIndex and Timestamp "
437437 with tm .assert_raises_regex (TypeError , msg ):
438438 idx + Timestamp ('2011-01-01' )
439439
440440 with tm .assert_raises_regex (TypeError , msg ):
441441 Timestamp ('2011-01-01' ) + idx
442442
443- def test_add_dti_dti (self ):
444- # previously performed setop (deprecated in 0.16.0), now raises
445- # TypeError (GH14164)
446-
447- dti = date_range ('20130101' , periods = 3 )
448- dti_tz = date_range ('20130101' , periods = 3 ).tz_localize ('US/Eastern' )
449-
450- with pytest .raises (TypeError ):
451- dti + dti
452-
453- with pytest .raises (TypeError ):
454- dti_tz + dti_tz
455-
456- with pytest .raises (TypeError ):
457- dti_tz + dti
458-
459- with pytest .raises (TypeError ):
460- dti + dti_tz
443+ @pytest .mark .parametrize ('addend' , [
444+ datetime (2011 , 1 , 1 ),
445+ DatetimeIndex (['2011-01-01' , '2011-01-02' ]),
446+ DatetimeIndex (['2011-01-01' , '2011-01-02' ])
447+ .tz_localize ('US/Eastern' ),
448+ np .datetime64 ('2011-01-01' ),
449+ Timestamp ('2011-01-01' ),
450+ ])
451+ def test_add_datetimelike_and_dti (self , addend ):
452+ # issue #9631
453+
454+ dti = DatetimeIndex (['2011-01-01' , '2011-01-02' ])
455+ msg = 'cannot add DatetimeIndex and {0}' .format (
456+ type (addend ).__name__ )
457+ with tm .assert_raises_regex (TypeError , msg ):
458+ dti + addend
459+ with tm .assert_raises_regex (TypeError , msg ):
460+ addend + dti
461+
462+ @pytest .mark .parametrize ('addend' , [
463+ datetime (2011 , 1 , 1 ),
464+ DatetimeIndex (['2011-01-01' , '2011-01-02' ]),
465+ DatetimeIndex (['2011-01-01' , '2011-01-02' ])
466+ .tz_localize ('US/Eastern' ),
467+ np .datetime64 ('2011-01-01' ),
468+ Timestamp ('2011-01-01' ),
469+ ])
470+ def test_add_datetimelike_and_dti_tz (self , addend ):
471+ # issue #9631
472+
473+ dti_tz = DatetimeIndex (['2011-01-01' , '2011-01-02' ]) \
474+ .tz_localize ('US/Eastern' )
475+ msg = 'cannot add DatetimeIndex and {0}' .format (
476+ type (addend ).__name__ )
477+ with tm .assert_raises_regex (TypeError , msg ):
478+ dti_tz + addend
479+ with tm .assert_raises_regex (TypeError , msg ):
480+ addend + dti_tz
461481
462482 def test_difference (self ):
463483 for tz in self .tz :
0 commit comments