Skip to content

Commit 4fb853f

Browse files
jbrockmendeljreback
authored andcommitted
TST/CLN: Exception catching (#28587)
1 parent 87b5153 commit 4fb853f

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

pandas/tests/indexing/test_iloc.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import pandas as pd
99
from pandas import DataFrame, Series, concat, date_range, isna
1010
from pandas.api.types import is_scalar
11+
from pandas.core.indexing import IndexingError
1112
from pandas.tests.indexing.common import Base
1213
from pandas.util import testing as tm
1314

@@ -722,7 +723,7 @@ def test_iloc_mask(self):
722723
else:
723724
accessor = df
724725
ans = str(bin(accessor[mask]["nums"].sum()))
725-
except Exception as e:
726+
except (ValueError, IndexingError, NotImplementedError) as e:
726727
ans = str(e)
727728

728729
key = tuple([idx, method])

pandas/tests/io/pytables/test_pytables.py

+3-9
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import pandas.util.testing as tm
3838
from pandas.util.testing import assert_frame_equal, assert_series_equal, set_timezone
3939

40-
from pandas.io.formats.printing import pprint_thing
4140
from pandas.io.pytables import (
4241
ClosedFileError,
4342
HDFStore,
@@ -3415,14 +3414,9 @@ def test_string_select(self):
34153414
expected = df[df.x == "none"]
34163415
assert_frame_equal(result, expected)
34173416

3418-
try:
3419-
result = store.select("df", "x!=none")
3420-
expected = df[df.x != "none"]
3421-
assert_frame_equal(result, expected)
3422-
except Exception as detail:
3423-
pprint_thing("[{0}]".format(detail))
3424-
pprint_thing(store)
3425-
pprint_thing(expected)
3417+
result = store.select("df", "x!=none")
3418+
expected = df[df.x != "none"]
3419+
assert_frame_equal(result, expected)
34263420

34273421
df2 = df.copy()
34283422
df2.loc[df2.x == "", "x"] = np.nan

pandas/util/testing.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from shutil import rmtree
1010
import string
1111
import tempfile
12-
import traceback
1312
from typing import Union, cast
1413
import warnings
1514
import zipfile
@@ -2291,10 +2290,7 @@ def wrapper(*args, **kwargs):
22912290
" and error {error}".format(error=e)
22922291
)
22932292

2294-
try:
2295-
e_str = traceback.format_exc(e)
2296-
except Exception:
2297-
e_str = str(e)
2293+
e_str = str(e)
22982294

22992295
if any(m.lower() in e_str.lower() for m in _skip_on_messages):
23002296
skip(

0 commit comments

Comments
 (0)