Skip to content

Commit 29d207a

Browse files
authored
Simplify error handling in parallel_testsuite (#25766)
The `test(result)` call already contains a try/catch for landing errors and skipping internally so the extra exception blocks here were not doing anything. What is more, if they ever did execute they would fail because the second argument to `addError` and `addSkip` is not an exception object but and exception info triple.
1 parent d13a1a7 commit 29d207a

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

test/parallel_testsuite.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,33 +51,27 @@ def run_test(args):
5151
if allowed_failures_counter and allowed_failures_counter.value < 0:
5252
return None
5353

54-
def test_failed():
55-
if allowed_failures_counter is not None:
56-
with lock:
57-
allowed_failures_counter.value -= 1
54+
# Handle setUpClass which needs to be called on each worker
55+
# TODO: Better handling of exceptions that happen during setUpClass
56+
if test.__class__ not in seen_class:
57+
seen_class.add(test.__class__)
58+
test.__class__.setUpClass()
5859

5960
start_time = time.perf_counter()
60-
6161
olddir = os.getcwd()
6262
result = BufferedParallelTestResult()
6363
result.start_time = start_time
6464
result.buffer = buffer
6565
temp_dir = tempfile.mkdtemp(prefix='emtest_')
6666
test.set_temp_dir(temp_dir)
6767
try:
68-
if test.__class__ not in seen_class:
69-
seen_class.add(test.__class__)
70-
test.__class__.setUpClass()
7168
test(result)
7269

7370
# Alert all other multiprocess pool runners that they need to stop executing further tests.
7471
if result.test_result not in ['success', 'skipped']:
75-
test_failed()
76-
except unittest.SkipTest as e:
77-
result.addSkip(test, e)
78-
except Exception as e:
79-
result.addError(test, e)
80-
test_failed()
72+
if allowed_failures_counter is not None:
73+
with lock:
74+
allowed_failures_counter.value -= 1
8175
finally:
8276
result.elapsed = time.perf_counter() - start_time
8377

0 commit comments

Comments
 (0)