diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py index e1d3f7f7e34..92a3d11cea2 100755 --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -923,6 +923,10 @@ def runtest_inner(test, verbose, quiet, def cleanup_test_droppings(testname, verbose): import shutil import stat + import gc + + # First kill any dangling references to open files etc. + gc.collect() # Try to clean up junk commonly left behind. While tests shouldn't leave # any files or directories behind, when a test fails that can be tedious