diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2012-03-02 01:01:13 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2012-03-02 01:01:13 (GMT) |
commit | f959618142888fab373c43edd35f20506a9740dc (patch) | |
tree | cc1f5a1bf7bac40e8b2913bb4c60522d875c4d22 /Lib/test/regrtest.py | |
parent | 4d2bfb5e08619581a9f205b6145f97e4b0d838df (diff) | |
download | cpython-f959618142888fab373c43edd35f20506a9740dc.zip cpython-f959618142888fab373c43edd35f20506a9740dc.tar.gz cpython-f959618142888fab373c43edd35f20506a9740dc.tar.bz2 |
Closes #14158: improved resilience to test files left behind.
Diffstat (limited to 'Lib/test/regrtest.py')
-rwxr-xr-x | Lib/test/regrtest.py | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py index 135a90e..714a116 100755 --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -677,10 +677,10 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, if bad: print(count(len(bad), "test"), "failed:") printlist(bad) - if environment_changed: - print("{} altered the execution environment:".format( - count(len(environment_changed), "test"))) - printlist(environment_changed) + if environment_changed: + print("{} altered the execution environment:".format( + count(len(environment_changed), "test"))) + printlist(environment_changed) if skipped and not quiet: print(count(len(skipped), "test"), "skipped:") printlist(skipped) @@ -890,7 +890,9 @@ class saved_test_environment: 'logging._handlers', 'logging._handlerList', 'shutil.archive_formats', 'shutil.unpack_formats', 'sys.warnoptions', 'threading._dangling', - 'multiprocessing.process._dangling') + 'multiprocessing.process._dangling', + 'support.TESTFN', + ) def get_sys_argv(self): return id(sys.argv), sys.argv, sys.argv[:] @@ -1020,6 +1022,21 @@ class saved_test_environment: multiprocessing.process._dangling.clear() multiprocessing.process._dangling.update(saved) + def get_support_TESTFN(self): + if os.path.isfile(support.TESTFN): + result = 'f' + elif os.path.isdir(support.TESTFN): + result = 'd' + else: + result = None + return result + def restore_support_TESTFN(self, saved_value): + if saved_value is None: + if os.path.isfile(support.TESTFN): + os.unlink(support.TESTFN) + elif os.path.isdir(support.TESTFN): + shutil.rmtree(support.TESTFN) + def resource_info(self): for name in self.resources: method_suffix = name.replace('.', '_') |