Serhiy Storchaka added the comment:
> I don't understand why you want to remove more files than before. You may
> open a different issue, or at least explain the rationale.
I thought it would be good idea slightly extend this cleanup while we are
here. I'm not motivated enough to open a different issue.
Well, here is a patch which removes only TESTFN. It is still improved, uses
support.unlink and support.rmtree instead of os.unlink and shutil.rmtree.
You can just drop cleanup code at all if you prefer. All is good to me.
> I never see any forgotten test file after running tests, so I don't see why
> you are worried because of them.
This is because regrtest creates temporary directory and goes to it. But when
you execute Python test directly, test files are created in the current
directory.
> And with your first patch, we will now
> noticed forgotten files, so we can just fix tests.
But we will noticed only one about test at the time if several tests forgot
the same file. This will needed several iterations.
----------
Added file: http://bugs.python.org/file36894/regrtest_warn_lost_files2.patch
_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22390>
_______________________________________
diff -r 1d5485471457 Lib/test/regrtest.py
--- a/Lib/test/regrtest.py Mon Oct 13 00:17:23 2014 -0500
+++ b/Lib/test/regrtest.py Mon Oct 13 11:10:36 2014 +0300
@@ -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_')]
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com