6
6
7
7
from pandas ._libs .tslib import iNaT
8
8
9
+ from pandas .core .dtypes .common import is_datetime64tz_dtype
9
10
from pandas .core .dtypes .dtypes import CategoricalDtype
10
11
11
12
import pandas as pd
@@ -301,6 +302,9 @@ def test_ensure_copied_data(self, indices):
301
302
302
303
index_type = type (indices )
303
304
result = index_type (indices .values , copy = True , ** init_kwargs )
305
+ if is_datetime64tz_dtype (indices .dtype ):
306
+ result = result .tz_localize ("UTC" ).tz_convert (indices .tz )
307
+
304
308
tm .assert_index_equal (indices , result )
305
309
tm .assert_numpy_array_equal (
306
310
indices ._ndarray_values , result ._ndarray_values , check_same = "copy"
@@ -464,6 +468,11 @@ def test_intersection_base(self, indices):
464
468
intersect = first .intersection (second )
465
469
assert tm .equalContents (intersect , second )
466
470
471
+ if is_datetime64tz_dtype (indices .dtype ):
472
+ # The second.values below will drop tz, so the rest of this test
473
+ # is not applicable.
474
+ return
475
+
467
476
# GH 10149
468
477
cases = [klass (second .values ) for klass in [np .array , Series , list ]]
469
478
for case in cases :
@@ -482,6 +491,11 @@ def test_union_base(self, indices):
482
491
union = first .union (second )
483
492
assert tm .equalContents (union , everything )
484
493
494
+ if is_datetime64tz_dtype (indices .dtype ):
495
+ # The second.values below will drop tz, so the rest of this test
496
+ # is not applicable.
497
+ return
498
+
485
499
# GH 10149
486
500
cases = [klass (second .values ) for klass in [np .array , Series , list ]]
487
501
for case in cases :
0 commit comments