8
8
import pytest
9
9
10
10
from pandas ._libs .tslibs import (
11
- OutOfBoundsDatetime ,
11
+ OutOfBoundsTimedelta ,
12
12
Timedelta ,
13
13
Timestamp ,
14
14
offsets ,
@@ -33,25 +33,20 @@ def test_overflow_offset(self):
33
33
expected = Timestamp ("1999/09/23" )
34
34
assert stamp - offset_no_overflow == expected
35
35
36
- def test_overflow_offset_raises (self ):
36
+ def test_overflow_offset_raises (self , td_overflow_msg : str ):
37
37
# xref https://github.com/statsmodels/statsmodels/issues/3374
38
38
# ends up multiplying really large numbers which overflow
39
39
40
40
stamp = Timestamp ("2017-01-13 00:00:00" )
41
41
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
- )
47
42
lmsg = "|" .join (
48
43
["Python int too large to convert to C long" , "int too big to convert" ]
49
44
)
50
45
51
46
with pytest .raises (OverflowError , match = lmsg ):
52
47
stamp + offset_overflow
53
48
54
- with pytest .raises (OverflowError , match = msg ):
49
+ with pytest .raises (OutOfBoundsTimedelta , match = td_overflow_msg ):
55
50
offset_overflow + stamp
56
51
57
52
with pytest .raises (OverflowError , match = lmsg ):
@@ -61,12 +56,12 @@ def test_overflow_offset_raises(self):
61
56
# used to crash, so check for proper overflow exception
62
57
63
58
stamp = Timestamp ("2000/1/1" )
64
- offset_overflow = to_offset ( "D" ) * 100 ** 5
59
+ offset_overflow = offsets . Day ( ) * 100 ** 5
65
60
66
61
with pytest .raises (OverflowError , match = lmsg ):
67
62
stamp + offset_overflow
68
63
69
- with pytest .raises (OverflowError , match = msg ):
64
+ with pytest .raises (OutOfBoundsTimedelta , match = td_overflow_msg ):
70
65
offset_overflow + stamp
71
66
72
67
with pytest .raises (OverflowError , match = lmsg ):
@@ -78,7 +73,7 @@ def test_overflow_timestamp_raises(self):
78
73
a = Timestamp ("2101-01-01 00:00:00" )
79
74
b = Timestamp ("1688-01-01 00:00:00" )
80
75
81
- with pytest .raises (OutOfBoundsDatetime , match = msg ):
76
+ with pytest .raises (OutOfBoundsTimedelta , match = msg ):
82
77
a - b
83
78
84
79
# but we're OK for timestamp and datetime.datetime
0 commit comments