[Python-checkins] cpython (2.7): Issue #22390: test.regrtest now emits a warning if temporary files or

serhiy.storchaka python-checkins at python.org
Mon Mar 30 00:31:19 CEST 2015


https://hg.python.org/cpython/rev/f40984e7ceea
changeset:   95253:f40984e7ceea
branch:      2.7
parent:      95242:b11f54a0f5e2
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Mon Mar 30 01:27:44 2015 +0300
summary:
  Issue #22390: test.regrtest now emits a warning if temporary files or
directories are left after running a test.

files:
  Lib/test/regrtest.py |  13 ++++++++++++-
  Misc/NEWS            |   3 +++
  2 files changed, 15 insertions(+), 1 deletions(-)


diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -773,7 +773,7 @@
 
     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 @@
             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('.', '_')
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -182,6 +182,9 @@
 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*.

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list