summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-03-29 22:30:22 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-03-29 22:30:22 (GMT)
commit10915aa85cf264caf6e606a10f1dd204663d6d5a (patch)
treee50ecc95e5328d1ddc882f1f8e21478b688c7808 /Lib/test
parent07360df481adeacfc2b7a1a7f89ae9a76e86b725 (diff)
parenta3a100b594982f10911f2c9db6cf954bb8ff8f20 (diff)
downloadcpython-10915aa85cf264caf6e606a10f1dd204663d6d5a.zip
cpython-10915aa85cf264caf6e606a10f1dd204663d6d5a.tar.gz
cpython-10915aa85cf264caf6e606a10f1dd204663d6d5a.tar.bz2
Issue #22390: test.regrtest now emits a warning if temporary files or
directories are left after running a test.
Diffstat (limited to 'Lib/test')
-rwxr-xr-xLib/test/regrtest.py26
1 files changed, 11 insertions, 15 deletions
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index ea1287d..7123ffb 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -1031,7 +1031,7 @@ class saved_test_environment:
# to a thread, so check processes first.
'multiprocessing.process._dangling', 'threading._dangling',
'sysconfig._CONFIG_VARS', 'sysconfig._INSTALL_SCHEMES',
- 'support.TESTFN', 'locale', 'warnings.showwarning',
+ 'files', 'locale', 'warnings.showwarning',
)
def get_sys_argv(self):
@@ -1187,20 +1187,16 @@ class saved_test_environment:
sysconfig._INSTALL_SCHEMES.clear()
sysconfig._INSTALL_SCHEMES.update(saved[2])
- 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 get_files(self):
+ return sorted(fn + ('/' if os.path.isdir(fn) else '')
+ for fn in os.listdir())
+ 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)
_lc = [getattr(locale, lc) for lc in dir(locale)
if lc.startswith('LC_')]