[Python-checkins] python/dist/src/Lib/test test_unicode_file.py, 1.13, 1.14

mondragon at users.sourceforge.net mondragon at users.sourceforge.net
Sun Mar 21 15:55:49 EST 2004


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22939/Lib/test

Modified Files:
	test_unicode_file.py 
Log Message:
Normalized files in test_unicode_file to eliminate failure on OSX


Index: test_unicode_file.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode_file.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** test_unicode_file.py	18 Jan 2004 20:29:55 -0000	1.13
--- test_unicode_file.py	21 Mar 2004 20:55:47 -0000	1.14
***************
*** 3,6 ****
--- 3,7 ----
  # that their names can be used with Unicode characters.
  import os, glob, time, shutil
+ import unicodedata
  
  import unittest
***************
*** 39,43 ****
          # basename should appear in listdir.
          path, base = os.path.split(os.path.abspath(filename))
!         self.failUnless(base in os.listdir(path))
  
      # Do as many "equivalancy' tests as we can - ie, check that although we
--- 40,54 ----
          # 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)
!         file_list = [unicodedata.normalize("NFD", f) for f in file_list]
! 
!         self.failUnless(new_base in file_list)
  
      # Do as many "equivalancy' tests as we can - ie, check that although we
***************
*** 92,96 ****
              os.unlink(filename1 + ".new")
  
!     def _do_directory(self, make_name, chdir_name, getcwd_func):
          cwd = os.getcwd()
          if os.path.isdir(make_name):
--- 103,107 ----
              os.unlink(filename1 + ".new")
  
!     def _do_directory(self, make_name, chdir_name, encoded):
          cwd = os.getcwd()
          if os.path.isdir(make_name):
***************
*** 100,105 ****
              os.chdir(chdir_name)
              try:
!                 self.failUnlessEqual(os.path.basename(getcwd_func()),
!                                      make_name)
              finally:
                  os.chdir(cwd)
--- 111,125 ----
              os.chdir(chdir_name)
              try:
!                 if not encoded:
!                     cwd_result = os.getcwdu()
!                     name_result = make_name
!                 else:
!                     cwd_result = os.getcwd().decode(TESTFN_ENCODING)
!                     name_result = make_name.decode(TESTFN_ENCODING)
! 
!                 cwd_result = unicodedata.normalize("NFD", cwd_result)
!                 name_result = unicodedata.normalize("NFD", name_result)
! 
!                 self.failUnlessEqual(os.path.basename(cwd_result),name_result)
              finally:
                  os.chdir(cwd)
***************
*** 153,165 ****
          #  (or unicode/encoded/unicode, etc
          ext = ".dir"
!         self._do_directory(TESTFN_ENCODED+ext, TESTFN_ENCODED+ext, os.getcwd)
!         self._do_directory(TESTFN_ENCODED+ext, TESTFN_UNICODE+ext, os.getcwd)
!         self._do_directory(TESTFN_UNICODE+ext, TESTFN_ENCODED+ext, os.getcwdu)
!         self._do_directory(TESTFN_UNICODE+ext, TESTFN_UNICODE+ext, os.getcwdu)
          # Our directory name that can't use a non-unicode name.
          if TESTFN_UNICODE_UNENCODEABLE is not None:
              self._do_directory(TESTFN_UNICODE_UNENCODEABLE+ext,
                                 TESTFN_UNICODE_UNENCODEABLE+ext,
!                                os.getcwdu)
  
  def test_main():
--- 173,185 ----
          #  (or unicode/encoded/unicode, etc
          ext = ".dir"
!         self._do_directory(TESTFN_ENCODED+ext, TESTFN_ENCODED+ext, True)
!         self._do_directory(TESTFN_ENCODED+ext, TESTFN_UNICODE+ext, True)
!         self._do_directory(TESTFN_UNICODE+ext, TESTFN_ENCODED+ext, False)
!         self._do_directory(TESTFN_UNICODE+ext, TESTFN_UNICODE+ext, False)
          # Our directory name that can't use a non-unicode name.
          if TESTFN_UNICODE_UNENCODEABLE is not None:
              self._do_directory(TESTFN_UNICODE_UNENCODEABLE+ext,
                                 TESTFN_UNICODE_UNENCODEABLE+ext,
!                                False)
  
  def test_main():




More information about the Python-checkins mailing list