Commit c8b5a2b2 authored by Raymond Hettinger's avatar Raymond Hettinger

Patch from Mark Hammond to fix a test error.

Now runs without exception on WinME/98.
parent 8b1f519f
...@@ -39,17 +39,20 @@ class TestUnicodeFiles(unittest.TestCase): ...@@ -39,17 +39,20 @@ class TestUnicodeFiles(unittest.TestCase):
os.path.abspath(filename)==os.path.abspath(glob.glob(filename)[0])) os.path.abspath(filename)==os.path.abspath(glob.glob(filename)[0]))
# basename should appear in listdir. # basename should appear in listdir.
path, base = os.path.split(os.path.abspath(filename)) path, base = os.path.split(os.path.abspath(filename))
if (isinstance (filename, str)): if isinstance(base, str):
new_base = base.decode(TESTFN_ENCODING) base = base.decode(TESTFN_ENCODING)
file_list = [f.decode(TESTFN_ENCODING) for f in os.listdir(path)]
else:
new_base = base
file_list = os.listdir(path) file_list = os.listdir(path)
# listdir() with a unicode arg may or may not return Unicode
new_base = unicodedata.normalize("NFD", new_base) # objects, depending on the platform.
if file_list and isinstance(file_list[0], str):
file_list = [f.decode(TESTFN_ENCODING) for f in file_list]
# Normalize the unicode strings, as round-tripping the name via the OS
# may return a different (but equivalent) value.
base = unicodedata.normalize("NFD", base)
file_list = [unicodedata.normalize("NFD", f) for f in file_list] file_list = [unicodedata.normalize("NFD", f) for f in file_list]
self.failUnless(new_base in file_list) self.failUnless(base in file_list)
# Do as many "equivalancy' tests as we can - ie, check that although we # Do as many "equivalancy' tests as we can - ie, check that although we
# have different types for the filename, they refer to the same file. # have different types for the filename, they refer to the same file.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment