Skip to content

Commit 2c16f74

Browse files
TST: fixed int-overflow test
1 parent 3508a9f commit 2c16f74

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

pandas/tests/io/parser/common/test_ints.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,14 @@ def _iinfo(dtype):
124124

125125
_raises_any_integer_cast_exception = pytest.raises( # noqa: PDF010
126126
(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+
]
133135
),
134136
)
135137

@@ -162,13 +164,13 @@ def test_integer_overflow_with_user_dtype(all_parsers, any_int_dtype, getval, ex
162164
):
163165
expected = tm.assert_produces_warning(
164166
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)}.",
166168
check_stacklevel=False,
167169
)
168170

169171
with expected:
170172
result = parser.read_csv(StringIO(data), dtype=dtype)
171-
if "result" in locals():
173+
if isinstance(expected, nullcontext):
172174
expected_result = DataFrame({"A": [val]}, dtype=dtype)
173175
tm.assert_frame_equal(result, expected_result)
174176

0 commit comments

Comments
 (0)