@@ -124,12 +124,14 @@ def _iinfo(dtype):
124
124
125
125
_raises_any_integer_cast_exception = pytest .raises ( # noqa: PDF010
126
126
(OverflowError , TypeError , ValueError ),
127
- match = (
128
- "(Overflow)|"
129
- "(Python int too large to convert to C long)|"
130
- "(cannot safely cast non-equivalent)|"
131
- "(Integer out of range)|"
132
- "(Unable to convert column)"
127
+ match = "|" .join (
128
+ [
129
+ "Overflow" ,
130
+ "cannot safely cast non-equivalent" ,
131
+ "Integer out of range" ,
132
+ "Unable to convert column" ,
133
+ "The elements provided in the data cannot all be casted to the dtype" ,
134
+ ]
133
135
),
134
136
)
135
137
@@ -162,13 +164,13 @@ def test_integer_overflow_with_user_dtype(all_parsers, any_int_dtype, getval, ex
162
164
):
163
165
expected = tm .assert_produces_warning (
164
166
FutureWarning ,
165
- match = f"Values are too large to be losslessly cast to { dtype } ." ,
167
+ match = f"Values are too large to be losslessly cast to { np . dtype ( dtype ) } ." ,
166
168
check_stacklevel = False ,
167
169
)
168
170
169
171
with expected :
170
172
result = parser .read_csv (StringIO (data ), dtype = dtype )
171
- if "result" in locals ( ):
173
+ if isinstance ( expected , nullcontext ):
172
174
expected_result = DataFrame ({"A" : [val ]}, dtype = dtype )
173
175
tm .assert_frame_equal (result , expected_result )
174
176
0 commit comments