]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #22390: test.regrtest now emits a warning if temporary files or
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 29 Mar 2015 22:27:44 +0000 (01:27 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Sun, 29 Mar 2015 22:27:44 +0000 (01:27 +0300)
directories are left after running a test.

Lib/test/regrtest.py
Misc/NEWS

index 9a872dcf7558ea893a4540d59bbe123f2502a280..3eaea03d0f81ddca966fbe597cf5cd68503285bd 100755 (executable)
@@ -773,7 +773,7 @@ class saved_test_environment:
 
     resources = ('sys.argv', 'cwd', 'sys.stdin', 'sys.stdout', 'sys.stderr',
                  'os.environ', 'sys.path', 'asyncore.socket_map',
-                 'test_support.TESTFN',
+                 'files',
                 )
 
     def get_sys_argv(self):
@@ -840,6 +840,17 @@ class saved_test_environment:
             elif os.path.isdir(test_support.TESTFN):
                 shutil.rmtree(test_support.TESTFN)
 
+    def get_files(self):
+        return sorted(fn + ('/' if os.path.isdir(fn) else '')
+                      for fn in os.listdir(os.curdir))
+    def restore_files(self, saved_value):
+        fn = support.TESTFN
+        if fn not in saved_value and (fn + '/') not in saved_value:
+            if os.path.isfile(fn):
+                support.unlink(fn)
+            elif os.path.isdir(fn):
+                support.rmtree(fn)
+
     def resource_info(self):
         for name in self.resources:
             method_suffix = name.replace('.', '_')
index 4d65d9aa2ba3756e562da2da1ead9c6df74f824d..9c3cd3d1862e813732fcd74bb6d721d87928237d 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -182,6 +182,9 @@ Tools/Demos
 Tests
 -----
 
+- Issue #22390: test.regrtest now emits a warning if temporary files or
+  directories are left after running a test.
+
 - Issue #23583: Added tests for standard IO streams in IDLE.
 
 - Issue #23392: Added tests for marshal C API that works with FILE*.