Reduced nesting inside DiscoverRunner.build_suite().

This commit is contained in:
Chris Jerdonek 2021-03-11 23:06:29 -08:00 committed by GitHub
parent d828beb68f
commit 551b0f94bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 8 deletions

View File

@ -589,14 +589,13 @@ class DiscoverRunner:
top_level = label_as_path top_level = label_as_path
while True: while True:
init_py = os.path.join(top_level, '__init__.py') init_py = os.path.join(top_level, '__init__.py')
if os.path.exists(init_py): if not os.path.exists(init_py):
try_next = os.path.dirname(top_level) break
if try_next == top_level: try_next = os.path.dirname(top_level)
# __init__.py all the way down? give up. if try_next == top_level:
break # __init__.py all the way down? give up.
top_level = try_next break
continue top_level = try_next
break
kwargs['top_level_dir'] = top_level kwargs['top_level_dir'] = top_level
if not (tests and tests.countTestCases()) and is_discoverable(label): if not (tests and tests.countTestCases()) and is_discoverable(label):