diff options
author | Raymond Hettinger <python@rcn.com> | 2004-06-28 06:57:19 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2004-06-28 06:57:19 (GMT) |
commit | 3b04ce824dfba83c5b736138b91aea07d0d2d5da (patch) | |
tree | 01a8305905d71c2ed826b771c0f4d5b6186de770 | |
parent | 19699a93513e5b011170123b0740bd9b7d714a53 (diff) | |
download | cpython-3b04ce824dfba83c5b736138b91aea07d0d2d5da.zip cpython-3b04ce824dfba83c5b736138b91aea07d0d2d5da.tar.gz cpython-3b04ce824dfba83c5b736138b91aea07d0d2d5da.tar.bz2 |
Patch from Mark Hammond to fix a test error.
Now runs without exception on WinME/98.
-rw-r--r-- | Lib/test/test_unicode_file.py | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/Lib/test/test_unicode_file.py b/Lib/test/test_unicode_file.py index 25733fd..e3ab5e6 100644 --- a/Lib/test/test_unicode_file.py +++ b/Lib/test/test_unicode_file.py @@ -39,17 +39,20 @@ class TestUnicodeFiles(unittest.TestCase): os.path.abspath(filename)==os.path.abspath(glob.glob(filename)[0])) # basename should appear in listdir. path, base = os.path.split(os.path.abspath(filename)) - if (isinstance (filename, str)): - new_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) - - new_base = unicodedata.normalize("NFD", new_base) + if isinstance(base, str): + base = base.decode(TESTFN_ENCODING) + file_list = os.listdir(path) + # listdir() with a unicode arg may or may not return Unicode + # 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] - 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 # have different types for the filename, they refer to the same file. |