Skip to content

Commit db51dc7

Browse files
committed
[bfops/fix-list-tests]: restore
1 parent fbc5e24 commit db51dc7

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

smoketests/__main__.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ def _convert_select_pattern(pattern):
5757

5858

5959
TESTPREFIX = "smoketests.tests."
60+
61+
def _iter_all_tests(suite_or_case):
62+
"""Yield all individual tests from possibly nested TestSuite structures."""
63+
if isinstance(suite_or_case, unittest.TestSuite):
64+
for t in suite_or_case:
65+
yield from _iter_all_tests(t)
66+
else:
67+
yield suite_or_case
68+
6069
def main():
6170
tests = [fname.removesuffix(".py") for fname in os.listdir(TEST_DIR / "tests") if fname.endswith(".py") and fname != "__init__.py"]
6271

@@ -108,8 +117,9 @@ def main():
108117
tests = loader.loadTestsFromNames(testlist)
109118
if args.list:
110119
print("Selected tests:\n")
111-
for test in itertools.chain(*itertools.chain(*tests)):
112-
print(f"{test}")
120+
for test in _iter_all_tests(tests):
121+
name = test.id()
122+
print(f"{name}")
113123
exit(0)
114124

115125
if not args.no_build_cli:

0 commit comments

Comments
 (0)