[Python-checkins] python/dist/src/Lib/test test_unicode_file.py,1.6,1.7

loewis@users.sourceforge.net loewis@users.sourceforge.net
Sat, 08 Mar 2003 02:25:34 -0800


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv25398

Modified Files:
	test_unicode_file.py 
Log Message:
Skip the test if TESTFN_ENCODING is None. Fixes #699386.


Index: test_unicode_file.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode_file.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** test_unicode_file.py	3 Oct 2002 05:10:38 -0000	1.6
--- test_unicode_file.py	8 Mar 2003 10:25:31 -0000	1.7
***************
*** 5,26 ****
  
  from test.test_support import verify, TestSkipped, TESTFN_UNICODE
  try:
!     from test.test_support import TESTFN_ENCODING
!     oldlocale = None
! except ImportError:
!     import locale
!     # try to run the test in an UTF-8 locale. If this locale is not
!     # available, avoid running the test since the locale's encoding
!     # might not support TESTFN_UNICODE. Likewise, if the system does
!     # not support locale.CODESET, Unicode file semantics is not
!     # available, either.
!     oldlocale = locale.setlocale(locale.LC_CTYPE)
!     try:
!         locale.setlocale(locale.LC_CTYPE,"en_US.UTF-8")
!         TESTFN_ENCODING = locale.nl_langinfo(locale.CODESET)
!     except (locale.Error, AttributeError):
!         raise TestSkipped("No Unicode filesystem semantics on this platform.")
! 
! TESTFN_ENCODED = TESTFN_UNICODE.encode(TESTFN_ENCODING)
  
  # Check with creation as Unicode string.
--- 5,15 ----
  
  from test.test_support import verify, TestSkipped, TESTFN_UNICODE
+ from test.test_support import TESTFN_ENCODING
  try:
!     TESTFN_ENCODED = TESTFN_UNICODE.encode(TESTFN_ENCODING)    
! except (ImportError, TypeError):
!     # Either the file system encoding is None, or the file name
!     # cannot be encoded in the file system encoding.
!     raise TestSkipped("No Unicode filesystem semantics on this platform.")
  
  # Check with creation as Unicode string.
***************
*** 105,108 ****
      os.rmdir(abs_encoded)
  print "All the Unicode tests appeared to work"
- if oldlocale:
-     locale.setlocale(locale.LC_CTYPE, oldlocale)
--- 94,95 ----