Let unittest._ShouldStop propagate through retry() so subTest+failfast works (#26616)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
ec78fa6518
commit
4f92e63c99
@@ -72,6 +72,7 @@ from typing import (
|
|||||||
Union,
|
Union,
|
||||||
)
|
)
|
||||||
from unittest import SkipTest
|
from unittest import SkipTest
|
||||||
|
from unittest.case import _ShouldStop
|
||||||
from urllib.parse import unquote, urlparse
|
from urllib.parse import unquote, urlparse
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@@ -2771,6 +2772,13 @@ def retry(
|
|||||||
except SkipTest:
|
except SkipTest:
|
||||||
# Do NOT retry skipped tests - used in CI and unittest
|
# Do NOT retry skipped tests - used in CI and unittest
|
||||||
raise
|
raise
|
||||||
|
except _ShouldStop:
|
||||||
|
# `unittest.case._ShouldStop` is raised by `subTest.__exit__`
|
||||||
|
# when a subtest fails/skips and `result.failfast` is True
|
||||||
|
# (CI invokes `python3 file.py -f`). It signals the outer
|
||||||
|
# `testPartExecutor` to stop the test method cleanly; do
|
||||||
|
# NOT retry, just propagate so unittest handles it.
|
||||||
|
raise
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user