@@ -250,13 +250,9 @@ def test_astype_str(self, data, request):
250
250
class TestConstructors (base .BaseConstructorsTests ):
251
251
def test_from_dtype (self , data , request ):
252
252
pa_dtype = data .dtype .pyarrow_dtype
253
- if (pa .types .is_timestamp (pa_dtype ) and pa_dtype .tz ) or pa .types .is_string (
254
- pa_dtype
255
- ):
256
- if pa .types .is_string (pa_dtype ):
257
- reason = "ArrowDtype(pa.string()) != StringDtype('pyarrow')"
258
- else :
259
- reason = f"pyarrow.type_for_alias cannot infer { pa_dtype } "
253
+
254
+ if pa .types .is_string (pa_dtype ):
255
+ reason = "ArrowDtype(pa.string()) != StringDtype('pyarrow')"
260
256
request .node .add_marker (
261
257
pytest .mark .xfail (
262
258
reason = reason ,
@@ -604,65 +600,24 @@ def test_in_numeric_groupby(self, data_for_grouping):
604
600
class TestBaseDtype (base .BaseDtypeTests ):
605
601
def test_construct_from_string_own_name (self , dtype , request ):
606
602
pa_dtype = dtype .pyarrow_dtype
607
- if pa .types .is_timestamp (pa_dtype ) and pa_dtype .tz is not None :
608
- request .node .add_marker (
609
- pytest .mark .xfail (
610
- raises = NotImplementedError ,
611
- reason = f"pyarrow.type_for_alias cannot infer { pa_dtype } " ,
612
- )
613
- )
614
- elif pa .types .is_string (pa_dtype ):
615
- request .node .add_marker (
616
- pytest .mark .xfail (
617
- raises = TypeError ,
618
- reason = (
619
- "Still support StringDtype('pyarrow') "
620
- "over ArrowDtype(pa.string())"
621
- ),
622
- )
623
- )
603
+
604
+ if pa .types .is_string (pa_dtype ):
605
+ # We still support StringDtype('pyarrow') over ArrowDtype(pa.string())
606
+ msg = r"string\[pyarrow\] should be constructed by StringDtype"
607
+ with pytest .raises (TypeError , match = msg ):
608
+ dtype .construct_from_string (dtype .name )
609
+
610
+ return
611
+
624
612
super ().test_construct_from_string_own_name (dtype )
625
613
626
614
def test_is_dtype_from_name (self , dtype , request ):
627
615
pa_dtype = dtype .pyarrow_dtype
628
- if pa .types .is_timestamp (pa_dtype ) and pa_dtype .tz is not None :
629
- request .node .add_marker (
630
- pytest .mark .xfail (
631
- raises = NotImplementedError ,
632
- reason = f"pyarrow.type_for_alias cannot infer { pa_dtype } " ,
633
- )
634
- )
635
- elif pa .types .is_string (pa_dtype ):
636
- request .node .add_marker (
637
- pytest .mark .xfail (
638
- reason = (
639
- "Still support StringDtype('pyarrow') "
640
- "over ArrowDtype(pa.string())"
641
- ),
642
- )
643
- )
644
- super ().test_is_dtype_from_name (dtype )
645
-
646
- def test_construct_from_string (self , dtype , request ):
647
- pa_dtype = dtype .pyarrow_dtype
648
- if pa .types .is_timestamp (pa_dtype ) and pa_dtype .tz is not None :
649
- request .node .add_marker (
650
- pytest .mark .xfail (
651
- raises = NotImplementedError ,
652
- reason = f"pyarrow.type_for_alias cannot infer { pa_dtype } " ,
653
- )
654
- )
655
- elif pa .types .is_string (pa_dtype ):
656
- request .node .add_marker (
657
- pytest .mark .xfail (
658
- raises = TypeError ,
659
- reason = (
660
- "Still support StringDtype('pyarrow') "
661
- "over ArrowDtype(pa.string())"
662
- ),
663
- )
664
- )
665
- super ().test_construct_from_string (dtype )
616
+ if pa .types .is_string (pa_dtype ):
617
+ # We still support StringDtype('pyarrow') over ArrowDtype(pa.string())
618
+ assert not type (dtype ).is_dtype (dtype .name )
619
+ else :
620
+ super ().test_is_dtype_from_name (dtype )
666
621
667
622
def test_construct_from_string_another_type_raises (self , dtype ):
668
623
msg = r"'another_type' must end with '\[pyarrow\]'"
@@ -753,13 +708,6 @@ def test_EA_types(self, engine, data, request):
753
708
request .node .add_marker (
754
709
pytest .mark .xfail (raises = TypeError , reason = "GH 47534" )
755
710
)
756
- elif pa .types .is_timestamp (pa_dtype ) and pa_dtype .tz is not None :
757
- request .node .add_marker (
758
- pytest .mark .xfail (
759
- raises = NotImplementedError ,
760
- reason = f"Parameterized types with tz={ pa_dtype .tz } not supported." ,
761
- )
762
- )
763
711
elif pa .types .is_timestamp (pa_dtype ) and pa_dtype .unit in ("us" , "ns" ):
764
712
request .node .add_marker (
765
713
pytest .mark .xfail (
@@ -1266,7 +1214,12 @@ def test_invalid_other_comp(self, data, comparison_op):
1266
1214
1267
1215
def test_arrowdtype_construct_from_string_type_with_unsupported_parameters ():
1268
1216
with pytest .raises (NotImplementedError , match = "Passing pyarrow type" ):
1269
- ArrowDtype .construct_from_string ("timestamp[s, tz=UTC][pyarrow]" )
1217
+ ArrowDtype .construct_from_string ("not_a_real_dype[s, tz=UTC][pyarrow]" )
1218
+
1219
+ # but as of GH#50689, timestamptz is supported
1220
+ dtype = ArrowDtype .construct_from_string ("timestamp[s, tz=UTC][pyarrow]" )
1221
+ expected = ArrowDtype (pa .timestamp ("s" , "UTC" ))
1222
+ assert dtype == expected
1270
1223
1271
1224
1272
1225
@pytest .mark .parametrize (
0 commit comments