@@ -436,7 +436,20 @@ def test_insert_index_float64(self, insert, coerced_val, coerced_dtype):
436
436
],
437
437
ids = ["datetime64" , "datetime64tz" ],
438
438
)
439
- def test_insert_index_datetimes (self , fill_val , exp_dtype ):
439
+ @pytest .mark .parametrize (
440
+ "insert_value" ,
441
+ [pd .Timestamp ("2012-01-01" ), pd .Timestamp ("2012-01-01" , tz = "Asia/Tokyo" ), 1 ],
442
+ )
443
+ def test_insert_index_datetimes (self , request , fill_val , exp_dtype , insert_value ):
444
+ if not hasattr (insert_value , "tz" ):
445
+ request .node .add_marker (
446
+ pytest .mark .xfail (reason = "ToDo: must coerce to object" )
447
+ )
448
+ elif fill_val .tz != insert_value .tz :
449
+ request .node .add_marker (
450
+ pytest .mark .xfail (reason = "GH 37605 - require tz equality?" )
451
+ )
452
+
440
453
obj = pd .DatetimeIndex (
441
454
["2011-01-01" , "2011-01-02" , "2011-01-03" , "2011-01-04" ], tz = fill_val .tz
442
455
)
@@ -448,25 +461,7 @@ def test_insert_index_datetimes(self, fill_val, exp_dtype):
448
461
)
449
462
self ._assert_insert_conversion (obj , fill_val , exp , exp_dtype )
450
463
451
- if fill_val .tz :
452
- msg = "Cannot compare tz-naive and tz-aware"
453
- with pytest .raises (TypeError , match = msg ):
454
- obj .insert (1 , pd .Timestamp ("2012-01-01" ))
455
-
456
- msg = "Timezones don't match"
457
- with pytest .raises (ValueError , match = msg ):
458
- obj .insert (1 , pd .Timestamp ("2012-01-01" , tz = "Asia/Tokyo" ))
459
-
460
- else :
461
- msg = "Cannot compare tz-naive and tz-aware"
462
- with pytest .raises (TypeError , match = msg ):
463
- obj .insert (1 , pd .Timestamp ("2012-01-01" , tz = "Asia/Tokyo" ))
464
-
465
- msg = "value should be a 'Timestamp' or 'NaT'. Got 'int' instead."
466
- with pytest .raises (TypeError , match = msg ):
467
- obj .insert (1 , 1 )
468
-
469
- pytest .xfail ("ToDo: must coerce to object" )
464
+ obj .insert (1 , insert_value )
470
465
471
466
def test_insert_index_timedelta64 (self ):
472
467
obj = pd .TimedeltaIndex (["1 day" , "2 day" , "3 day" , "4 day" ])
0 commit comments