@@ -770,12 +770,8 @@ def test_constructor_cast(self):
770
770
771
771
def test_constructor_signed_int_overflow_raises (self ):
772
772
# GH#41734 disallow silent overflow, enforced in 2.0
773
- if np_version_gt2 :
774
- msg = "The elements provided in the data cannot all be casted to the dtype"
775
- err = OverflowError
776
- else :
777
- msg = "Values are too large to be losslessly converted"
778
- err = ValueError
773
+ msg = "Values are too large to be losslessly converted"
774
+ err = ValueError
779
775
with pytest .raises (err , match = msg ):
780
776
Series ([1 , 200 , 923442 ], dtype = "int8" )
781
777
@@ -803,13 +799,7 @@ def test_constructor_numpy_uints(self, values):
803
799
804
800
def test_constructor_unsigned_dtype_overflow (self , any_unsigned_int_numpy_dtype ):
805
801
# see gh-15832
806
- if np_version_gt2 :
807
- msg = (
808
- f"The elements provided in the data cannot "
809
- f"all be casted to the dtype { any_unsigned_int_numpy_dtype } "
810
- )
811
- else :
812
- msg = "Trying to coerce negative values to unsigned integers"
802
+ msg = "Trying to coerce negative values to unsigned integers"
813
803
with pytest .raises (OverflowError , match = msg ):
814
804
Series ([- 1 ], dtype = any_unsigned_int_numpy_dtype )
815
805
@@ -1939,15 +1929,9 @@ def test_constructor_int64_dtype(self, any_int_dtype):
1939
1929
1940
1930
def test_constructor_raise_on_lossy_conversion_of_strings (self ):
1941
1931
# GH#44923
1942
- if not np_version_gt2 :
1943
- raises = pytest .raises (
1944
- ValueError , match = "string values cannot be losslessly cast to int8"
1945
- )
1946
- else :
1947
- raises = pytest .raises (
1948
- OverflowError , match = "The elements provided in the data"
1949
- )
1950
- with raises :
1932
+ with pytest .raises (
1933
+ ValueError , match = "string values cannot be losslessly cast to int8"
1934
+ ):
1951
1935
Series (["128" ], dtype = "int8" )
1952
1936
1953
1937
def test_constructor_dtype_timedelta_alternative_construct (self ):
0 commit comments