@@ -82,78 +82,63 @@ def cmp(a, b):
82
82
83
83
84
84
# ----------------------------------------------------------------------------
85
- class BaseDatetimeTests :
86
- pass
85
+ class TestDatetimeArray (base .ExtensionTests ):
86
+ def _get_expected_exception (self , op_name , obj , other ):
87
+ if op_name in ["__sub__" , "__rsub__" ]:
88
+ return None
89
+ return super ()._get_expected_exception (op_name , obj , other )
87
90
91
+ def _supports_accumulation (self , ser , op_name : str ) -> bool :
92
+ return op_name in ["cummin" , "cummax" ]
88
93
89
- # ----------------------------------------------------------------------------
90
- # Tests
91
- class TestDatetimeDtype (BaseDatetimeTests , base .BaseDtypeTests ):
92
- pass
94
+ def _supports_reduction (self , obj , op_name : str ) -> bool :
95
+ return op_name in ["min" , "max" , "median" , "mean" , "std" , "any" , "all" ]
93
96
97
+ @pytest .mark .parametrize ("skipna" , [True , False ])
98
+ def test_reduce_series_boolean (self , data , all_boolean_reductions , skipna ):
99
+ meth = all_boolean_reductions
100
+ msg = f"'{ meth } ' with datetime64 dtypes is deprecated and will raise in"
101
+ with tm .assert_produces_warning (
102
+ FutureWarning , match = msg , check_stacklevel = False
103
+ ):
104
+ super ().test_reduce_series_boolean (data , all_boolean_reductions , skipna )
94
105
95
- class TestConstructors (BaseDatetimeTests , base .BaseConstructorsTests ):
96
106
def test_series_constructor (self , data ):
97
107
# Series construction drops any .freq attr
98
108
data = data ._with_freq (None )
99
109
super ().test_series_constructor (data )
100
110
101
-
102
- class TestGetitem (BaseDatetimeTests , base .BaseGetitemTests ):
103
- pass
104
-
105
-
106
- class TestIndex (base .BaseIndexTests ):
107
- pass
108
-
109
-
110
- class TestMethods (BaseDatetimeTests , base .BaseMethodsTests ):
111
111
@pytest .mark .parametrize ("na_action" , [None , "ignore" ])
112
112
def test_map (self , data , na_action ):
113
113
result = data .map (lambda x : x , na_action = na_action )
114
114
tm .assert_extension_array_equal (result , data )
115
115
116
-
117
- class TestInterface (BaseDatetimeTests , base .BaseInterfaceTests ):
118
- pass
119
-
120
-
121
- class TestArithmeticOps (BaseDatetimeTests , base .BaseArithmeticOpsTests ):
122
- implements = {"__sub__" , "__rsub__" }
123
-
124
- def _get_expected_exception (self , op_name , obj , other ):
125
- if op_name in self .implements :
126
- return None
127
- return super ()._get_expected_exception (op_name , obj , other )
128
-
129
-
130
- class TestCasting (BaseDatetimeTests , base .BaseCastingTests ):
131
- pass
132
-
133
-
134
- class TestComparisonOps (BaseDatetimeTests , base .BaseComparisonOpsTests ):
135
- pass
136
-
137
-
138
- class TestMissing (BaseDatetimeTests , base .BaseMissingTests ):
139
- pass
140
-
141
-
142
- class TestReshaping (BaseDatetimeTests , base .BaseReshapingTests ):
143
- pass
144
-
145
-
146
- class TestSetitem (BaseDatetimeTests , base .BaseSetitemTests ):
147
- pass
148
-
149
-
150
- class TestGroupby (BaseDatetimeTests , base .BaseGroupbyTests ):
151
- pass
152
-
153
-
154
- class TestPrinting (BaseDatetimeTests , base .BasePrintingTests ):
155
- pass
156
-
157
-
158
- class Test2DCompat (BaseDatetimeTests , base .NDArrayBacked2DTests ):
116
+ @pytest .mark .parametrize ("engine" , ["c" , "python" ])
117
+ def test_EA_types (self , engine , data ):
118
+ expected_msg = r".*must implement _from_sequence_of_strings.*"
119
+ with pytest .raises (NotImplementedError , match = expected_msg ):
120
+ super ().test_EA_types (engine , data )
121
+
122
+ def check_reduce (self , ser : pd .Series , op_name : str , skipna : bool ):
123
+ if op_name in ["median" , "mean" , "std" ]:
124
+ alt = ser .astype ("int64" )
125
+
126
+ res_op = getattr (ser , op_name )
127
+ exp_op = getattr (alt , op_name )
128
+ result = res_op (skipna = skipna )
129
+ expected = exp_op (skipna = skipna )
130
+ if op_name in ["mean" , "median" ]:
131
+ # error: Item "dtype[Any]" of "dtype[Any] | ExtensionDtype"
132
+ # has no attribute "tz"
133
+ tz = ser .dtype .tz # type: ignore[union-attr]
134
+ expected = pd .Timestamp (expected , tz = tz )
135
+ else :
136
+ expected = pd .Timedelta (expected )
137
+ tm .assert_almost_equal (result , expected )
138
+
139
+ else :
140
+ return super ().check_reduce (ser , op_name , skipna )
141
+
142
+
143
+ class Test2DCompat (base .NDArrayBacked2DTests ):
159
144
pass
0 commit comments