Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions 16 Lib/test/regrtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,13 @@ def format_test_result(test_name, result):
return fmt % test_name


def unload_test_modules(save_modules):
# Unload the newly imported modules (best effort finalization)
for module in sys.modules.keys():
if module not in save_modules and module.startswith("test."):
test_support.unload(module)


def main(tests=None, testdir=None, verbose=0, quiet=False,
exclude=False, single=False, randomize=False, fromfile=None,
findleaks=False, use_resources=None, trace=False, coverdir='coverage',
Expand Down Expand Up @@ -835,10 +842,8 @@ def local_runtest():
# them again
found_garbage.extend(gc.garbage)
del gc.garbage[:]
# Unload the newly imported modules (best effort finalization)
for module in sys.modules.keys():
if module not in save_modules and module.startswith("test."):
test_support.unload(module)

unload_test_modules(save_modules)

if interrupted and not pgo:
# print a newline after ^C
Expand Down Expand Up @@ -1543,6 +1548,7 @@ def list_cases(testdir, selected, match_tests):
test_support.verbose = False
test_support.match_tests = match_tests

save_modules = set(sys.modules)
skipped = []
for test in selected:
abstest = get_abs_module(testdir, test)
Expand All @@ -1552,6 +1558,8 @@ def list_cases(testdir, selected, match_tests):
except unittest.SkipTest:
skipped.append(test)

unload_test_modules(save_modules)

if skipped:
print >>sys.stderr
print >>sys.stderr, count(len(skipped), "test"), "skipped:"
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.