[Python-checkins] cpython (3.4): Fix sporadic failure of test_pep277 on Windows: use support.rmtree() instead of
victor.stinner
python-checkins at python.org
Tue Jul 29 00:46:40 CEST 2014
http://hg.python.org/cpython/rev/bc70c1da7faf
changeset: 91909:bc70c1da7faf
branch: 3.4
parent: 91907:f618f6739200
user: Victor Stinner <victor.stinner at gmail.com>
date: Tue Jul 29 00:40:50 2014 +0200
summary:
Fix sporadic failure of test_pep277 on Windows: use support.rmtree() instead of
deltree().
files:
Lib/test/test_pep277.py | 33 +++++++---------------------
1 files changed, 9 insertions(+), 24 deletions(-)
diff --git a/Lib/test/test_pep277.py b/Lib/test/test_pep277.py
--- a/Lib/test/test_pep277.py
+++ b/Lib/test/test_pep277.py
@@ -56,17 +56,6 @@
"Unicode-friendly filesystem encoding")
-# Destroy directory dirname and all files under it, to one level.
-def deltree(dirname):
- # Don't hide legitimate errors: if one of these suckers exists, it's
- # an error if we can't remove it.
- if os.path.exists(dirname):
- # must pass unicode to os.listdir() so we get back unicode results.
- for fname in os.listdir(str(dirname)):
- os.unlink(os.path.join(dirname, fname))
- os.rmdir(dirname)
-
-
class UnicodeFileTests(unittest.TestCase):
files = set(filenames)
normal_form = None
@@ -76,6 +65,8 @@
os.mkdir(support.TESTFN)
except FileExistsError:
pass
+ self.addCleanup(support.rmtree, support.TESTFN)
+
files = set()
for name in self.files:
name = os.path.join(support.TESTFN, self.norm(name))
@@ -85,9 +76,6 @@
files.add(name)
self.files = files
- def tearDown(self):
- deltree(support.TESTFN)
-
def norm(self, s):
if self.normal_form:
return normalize(self.normal_form, s)
@@ -200,16 +188,13 @@
def test_main():
- try:
- support.run_unittest(
- UnicodeFileTests,
- UnicodeNFCFileTests,
- UnicodeNFDFileTests,
- UnicodeNFKCFileTests,
- UnicodeNFKDFileTests,
- )
- finally:
- deltree(support.TESTFN)
+ support.run_unittest(
+ UnicodeFileTests,
+ UnicodeNFCFileTests,
+ UnicodeNFDFileTests,
+ UnicodeNFKCFileTests,
+ UnicodeNFKDFileTests,
+ )
if __name__ == "__main__":
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list