88import pytest
99
1010from pandas ._libs .tslibs import (
11- OutOfBoundsDatetime ,
11+ OutOfBoundsTimedelta ,
1212 Timedelta ,
1313 Timestamp ,
1414 offsets ,
@@ -33,25 +33,20 @@ def test_overflow_offset(self):
3333 expected = Timestamp ("1999/09/23" )
3434 assert stamp - offset_no_overflow == expected
3535
36- def test_overflow_offset_raises (self ):
36+ def test_overflow_offset_raises (self , td_overflow_msg : str ):
3737 # xref https://github.com/statsmodels/statsmodels/issues/3374
3838 # ends up multiplying really large numbers which overflow
3939
4040 stamp = Timestamp ("2017-01-13 00:00:00" )
4141 offset_overflow = 20169940 * offsets .Day (1 )
42- msg = (
43- "the add operation between "
44- r"\<-?\d+ \* Days\> and \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} "
45- "will overflow"
46- )
4742 lmsg = "|" .join (
4843 ["Python int too large to convert to C long" , "int too big to convert" ]
4944 )
5045
5146 with pytest .raises (OverflowError , match = lmsg ):
5247 stamp + offset_overflow
5348
54- with pytest .raises (OverflowError , match = msg ):
49+ with pytest .raises (OutOfBoundsTimedelta , match = td_overflow_msg ):
5550 offset_overflow + stamp
5651
5752 with pytest .raises (OverflowError , match = lmsg ):
@@ -61,12 +56,12 @@ def test_overflow_offset_raises(self):
6156 # used to crash, so check for proper overflow exception
6257
6358 stamp = Timestamp ("2000/1/1" )
64- offset_overflow = to_offset ( "D" ) * 100 ** 5
59+ offset_overflow = offsets . Day ( ) * 100 ** 5
6560
6661 with pytest .raises (OverflowError , match = lmsg ):
6762 stamp + offset_overflow
6863
69- with pytest .raises (OverflowError , match = msg ):
64+ with pytest .raises (OutOfBoundsTimedelta , match = td_overflow_msg ):
7065 offset_overflow + stamp
7166
7267 with pytest .raises (OverflowError , match = lmsg ):
@@ -78,7 +73,7 @@ def test_overflow_timestamp_raises(self):
7873 a = Timestamp ("2101-01-01 00:00:00" )
7974 b = Timestamp ("1688-01-01 00:00:00" )
8075
81- with pytest .raises (OutOfBoundsDatetime , match = msg ):
76+ with pytest .raises (OutOfBoundsTimedelta , match = msg ):
8277 a - b
8378
8479 # but we're OK for timestamp and datetime.datetime
0 commit comments