Skip to content

Commit d96d6b0

Browse files
TST: specified expected exception
1 parent 88d8650 commit d96d6b0

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

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

+12-5
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,15 @@ def _iinfo(dtype):
122122
return iinfo
123123

124124

125-
_raises_int_overflow = pytest.raises( # noqa: PDF010
126-
(OverflowError, TypeError, ValueError), match=None
125+
_raises_any_integer_cast_exception = pytest.raises( # noqa: PDF010
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)"
133+
),
127134
)
128135

129136

@@ -133,8 +140,8 @@ def _iinfo(dtype):
133140
[
134141
(lambda dtype: _iinfo(dtype).max, nullcontext()), # in range does not raise
135142
(lambda dtype: _iinfo(dtype).min, nullcontext()), # in range does not raise
136-
(lambda dtype: _iinfo(dtype).max + 1, _raises_int_overflow),
137-
(lambda dtype: _iinfo(dtype).min - 1, _raises_int_overflow),
143+
(lambda dtype: _iinfo(dtype).max + 1, _raises_any_integer_cast_exception),
144+
(lambda dtype: _iinfo(dtype).min - 1, _raises_any_integer_cast_exception),
138145
],
139146
)
140147
def test_integer_overflow_with_user_dtype(all_parsers, any_int_dtype, getval, expected):
@@ -147,7 +154,7 @@ def test_integer_overflow_with_user_dtype(all_parsers, any_int_dtype, getval, ex
147154
# int8, int16, int32 only throw a FutureWarning until deprecation from #41734
148155
# becomes enforced. After enforcement, the following block must be deleted.
149156
if (
150-
(expected is _raises_int_overflow)
157+
(expected == _raises_any_integer_cast_exception)
151158
and (parser.engine == "python")
152159
and (not is_extension_array_dtype(dtype))
153160
and (dtype < np.dtype("int64"))

0 commit comments

Comments
 (0)