diff --git a/pandas/tests/indexing/test_iloc.py b/pandas/tests/indexing/test_iloc.py index 85eab91af3c48..c3ba5c0545b8b 100644 --- a/pandas/tests/indexing/test_iloc.py +++ b/pandas/tests/indexing/test_iloc.py @@ -8,6 +8,7 @@ import pandas as pd from pandas import DataFrame, Series, concat, date_range, isna from pandas.api.types import is_scalar +from pandas.core.indexing import IndexingError from pandas.tests.indexing.common import Base from pandas.util import testing as tm @@ -722,7 +723,7 @@ def test_iloc_mask(self): else: accessor = df ans = str(bin(accessor[mask]["nums"].sum())) - except Exception as e: + except (ValueError, IndexingError, NotImplementedError) as e: ans = str(e) key = tuple([idx, method]) diff --git a/pandas/tests/io/pytables/test_pytables.py b/pandas/tests/io/pytables/test_pytables.py index 856d97e29f2c0..ae604b1141204 100644 --- a/pandas/tests/io/pytables/test_pytables.py +++ b/pandas/tests/io/pytables/test_pytables.py @@ -37,7 +37,6 @@ import pandas.util.testing as tm from pandas.util.testing import assert_frame_equal, assert_series_equal, set_timezone -from pandas.io.formats.printing import pprint_thing from pandas.io.pytables import ( ClosedFileError, HDFStore, @@ -3415,14 +3414,9 @@ def test_string_select(self): expected = df[df.x == "none"] assert_frame_equal(result, expected) - try: - result = store.select("df", "x!=none") - expected = df[df.x != "none"] - assert_frame_equal(result, expected) - except Exception as detail: - pprint_thing("[{0}]".format(detail)) - pprint_thing(store) - pprint_thing(expected) + result = store.select("df", "x!=none") + expected = df[df.x != "none"] + assert_frame_equal(result, expected) df2 = df.copy() df2.loc[df2.x == "", "x"] = np.nan diff --git a/pandas/util/testing.py b/pandas/util/testing.py index af726caa52e88..aee58f808d9e6 100644 --- a/pandas/util/testing.py +++ b/pandas/util/testing.py @@ -9,7 +9,6 @@ from shutil import rmtree import string import tempfile -import traceback from typing import Union, cast import warnings import zipfile @@ -2291,10 +2290,7 @@ def wrapper(*args, **kwargs): " and error {error}".format(error=e) ) - try: - e_str = traceback.format_exc(e) - except Exception: - e_str = str(e) + e_str = str(e) if any(m.lower() in e_str.lower() for m in _skip_on_messages): skip(