Skip to content

Commit 4572a1a

Browse files
committed
unittest: Optimise calling of _handle_test_exception.
Signed-off-by: Damien George <damien@micropython.org>
1 parent 3756e09 commit 4572a1a

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

‎python-stdlib/unittest/unittest/__init__.py‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ def __init__(self, msg=None, params=None):
4040
def __enter__(self):
4141
pass
4242

43-
def __exit__(self, *exc_info):
44-
if exc_info[0] is not None:
43+
def __exit__(self, exc_type, exc_value, tb):
44+
if exc_type is not None:
4545
# Exception raised
4646
global __test_result__, __current_test__
4747
test_details = __current_test__
@@ -323,9 +323,8 @@ def __add__(self, other):
323323

324324

325325
def _handle_test_exception(
326-
current_test: tuple, test_result: TestResult, exc_info: tuple, verbose=True
326+
current_test: tuple, test_result: TestResult, exc: Exception, verbose=True
327327
):
328-
exc = exc_info[1]
329328
if isinstance(exc, SkipTest):
330329
reason = exc.args[0]
331330
test_result.skippedNum += 1
@@ -384,9 +383,7 @@ def run_one(test_function):
384383
else:
385384
print(" ok")
386385
except Exception as ex:
387-
_handle_test_exception(
388-
current_test=(name, c), test_result=test_result, exc_info=(type(ex), ex, None)
389-
)
386+
_handle_test_exception((name, c), test_result, ex)
390387
# Uncomment to investigate failure in detail
391388
# raise ex
392389
finally:

0 commit comments

Comments
 (0)