Skip to content

Commit 08af93a

Browse files
ShaharNavehjorisvandenbossche
authored andcommitted
TST: Replaced try-catch blocks with pytest.raises (#31165)
1 parent 590e20c commit 08af93a

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

pandas/tests/test_errors.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ def test_exception_importable(exc):
3636
def test_catch_oob():
3737
from pandas import errors
3838

39-
try:
39+
msg = "Out of bounds nanosecond timestamp: 1500-01-01 00:00:00"
40+
with pytest.raises(errors.OutOfBoundsDatetime, match=msg):
4041
pd.Timestamp("15000101")
41-
except errors.OutOfBoundsDatetime:
42-
pass
4342

4443

4544
class Foo:

pandas/tests/util/test_assert_frame_equal.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,9 @@ def _assert_not_frame_equal(a, b, **kwargs):
4646
kwargs : dict
4747
The arguments passed to `tm.assert_frame_equal`.
4848
"""
49-
try:
49+
msg = "The two DataFrames were equal when they shouldn't have been"
50+
with pytest.raises(AssertionError, match=msg):
5051
tm.assert_frame_equal(a, b, **kwargs)
51-
msg = "The two DataFrames were equal when they shouldn't have been"
52-
53-
pytest.fail(msg=msg)
54-
except AssertionError:
55-
pass
5652

5753

5854
def _assert_not_frame_equal_both(a, b, **kwargs):

0 commit comments

Comments
 (0)