8
8
from pandas ._libs import lib
9
9
from pandas ._libs .tslib import iNaT
10
10
11
+ from pandas .core .construction import create_series_with_explicit_index_type
11
12
from pandas .core .dtypes .common import is_categorical_dtype , is_datetime64tz_dtype
12
13
from pandas .core .dtypes .dtypes import CategoricalDtype
13
14
@@ -134,12 +135,21 @@ def test_constructor_empty(self, input_class):
134
135
135
136
# With explicit dtype:
136
137
empty = Series (dtype = "float64" )
137
- empty2 = Series (input_class (), dtype = "float64" )
138
+
139
+ if input_class is list :
140
+ with tm .assert_produces_warning (DeprecationWarning , check_stacklevel = False ):
141
+ empty2 = Series (input_class (), dtype = "float64" )
142
+ else :
143
+ empty2 = Series (input_class (), dtype = "float64" )
138
144
tm .assert_series_equal (empty , empty2 , check_index_type = False )
139
145
140
146
# GH 18515 : with dtype=category:
141
147
empty = Series (dtype = "category" )
142
- empty2 = Series (input_class (), dtype = "category" )
148
+ if input_class is list :
149
+ with tm .assert_produces_warning (DeprecationWarning , check_stacklevel = False ):
150
+ empty2 = Series (input_class (), dtype = "category" )
151
+ else :
152
+ empty2 = Series (input_class (), dtype = "category" )
143
153
tm .assert_series_equal (empty , empty2 , check_index_type = False )
144
154
145
155
if input_class is not list :
@@ -1391,7 +1401,7 @@ def test_constructor_generic_timestamp_no_frequency(self, dtype):
1391
1401
msg = "dtype has no unit. Please pass in"
1392
1402
1393
1403
with pytest .raises (ValueError , match = msg ):
1394
- Series ([], dtype = dtype )
1404
+ create_series_with_explicit_index_type ([], dtype = dtype )
1395
1405
1396
1406
@pytest .mark .parametrize (
1397
1407
"dtype,msg" ,
@@ -1404,7 +1414,7 @@ def test_constructor_generic_timestamp_bad_frequency(self, dtype, msg):
1404
1414
# see gh-15524, gh-15987
1405
1415
1406
1416
with pytest .raises (TypeError , match = msg ):
1407
- Series ([], dtype = dtype )
1417
+ create_series_with_explicit_index_type ([], dtype = dtype )
1408
1418
1409
1419
@pytest .mark .parametrize ("dtype" , [None , "uint8" , "category" ])
1410
1420
def test_constructor_range_dtype (self , dtype ):
0 commit comments