88from pandas ._libs import lib
99from pandas ._libs .tslib import iNaT
1010
11+ from pandas .core .construction import create_series_with_explicit_index_type
1112from pandas .core .dtypes .common import is_categorical_dtype , is_datetime64tz_dtype
1213from pandas .core .dtypes .dtypes import CategoricalDtype
1314
@@ -134,12 +135,21 @@ def test_constructor_empty(self, input_class):
134135
135136 # With explicit dtype:
136137 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" )
138144 tm .assert_series_equal (empty , empty2 , check_index_type = False )
139145
140146 # GH 18515 : with dtype=category:
141147 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" )
143153 tm .assert_series_equal (empty , empty2 , check_index_type = False )
144154
145155 if input_class is not list :
@@ -1391,7 +1401,7 @@ def test_constructor_generic_timestamp_no_frequency(self, dtype):
13911401 msg = "dtype has no unit. Please pass in"
13921402
13931403 with pytest .raises (ValueError , match = msg ):
1394- Series ([], dtype = dtype )
1404+ create_series_with_explicit_index_type ([], dtype = dtype )
13951405
13961406 @pytest .mark .parametrize (
13971407 "dtype,msg" ,
@@ -1404,7 +1414,7 @@ def test_constructor_generic_timestamp_bad_frequency(self, dtype, msg):
14041414 # see gh-15524, gh-15987
14051415
14061416 with pytest .raises (TypeError , match = msg ):
1407- Series ([], dtype = dtype )
1417+ create_series_with_explicit_index_type ([], dtype = dtype )
14081418
14091419 @pytest .mark .parametrize ("dtype" , [None , "uint8" , "category" ])
14101420 def test_constructor_range_dtype (self , dtype ):
0 commit comments