Fix sporadic failure of test_pep277 on Windows: use support.rmtree() instead of
deltree().
This commit is contained in:
parent
e0e65817e5
commit
0970657f01
|
@ -56,17 +56,6 @@ if not os.path.supports_unicode_filenames:
|
||||||
"Unicode-friendly filesystem encoding")
|
"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):
|
class UnicodeFileTests(unittest.TestCase):
|
||||||
files = set(filenames)
|
files = set(filenames)
|
||||||
normal_form = None
|
normal_form = None
|
||||||
|
@ -76,6 +65,8 @@ class UnicodeFileTests(unittest.TestCase):
|
||||||
os.mkdir(support.TESTFN)
|
os.mkdir(support.TESTFN)
|
||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
pass
|
pass
|
||||||
|
self.addCleanup(support.rmtree, support.TESTFN)
|
||||||
|
|
||||||
files = set()
|
files = set()
|
||||||
for name in self.files:
|
for name in self.files:
|
||||||
name = os.path.join(support.TESTFN, self.norm(name))
|
name = os.path.join(support.TESTFN, self.norm(name))
|
||||||
|
@ -85,9 +76,6 @@ class UnicodeFileTests(unittest.TestCase):
|
||||||
files.add(name)
|
files.add(name)
|
||||||
self.files = files
|
self.files = files
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
deltree(support.TESTFN)
|
|
||||||
|
|
||||||
def norm(self, s):
|
def norm(self, s):
|
||||||
if self.normal_form:
|
if self.normal_form:
|
||||||
return normalize(self.normal_form, s)
|
return normalize(self.normal_form, s)
|
||||||
|
@ -200,16 +188,13 @@ class UnicodeNFKDFileTests(UnicodeFileTests):
|
||||||
|
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
try:
|
support.run_unittest(
|
||||||
support.run_unittest(
|
UnicodeFileTests,
|
||||||
UnicodeFileTests,
|
UnicodeNFCFileTests,
|
||||||
UnicodeNFCFileTests,
|
UnicodeNFDFileTests,
|
||||||
UnicodeNFDFileTests,
|
UnicodeNFKCFileTests,
|
||||||
UnicodeNFKCFileTests,
|
UnicodeNFKDFileTests,
|
||||||
UnicodeNFKDFileTests,
|
)
|
||||||
)
|
|
||||||
finally:
|
|
||||||
deltree(support.TESTFN)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in New Issue