summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_unicode_file.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2003-03-08 10:25:31 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2003-03-08 10:25:31 (GMT)
commitc49435c991e02d175858fd1e04f87b94dd1177b4 (patch)
treee04b29a29bcfe52a5df4e7864a364c6d2b1ffc2f /Lib/test/test_unicode_file.py
parent33975eac3d03563513388c571f0704bb17e6f38b (diff)
downloadcpython-c49435c991e02d175858fd1e04f87b94dd1177b4.zip
cpython-c49435c991e02d175858fd1e04f87b94dd1177b4.tar.gz
cpython-c49435c991e02d175858fd1e04f87b94dd1177b4.tar.bz2
Skip the test if TESTFN_ENCODING is None. Fixes #699386.
Diffstat (limited to 'Lib/test/test_unicode_file.py')
-rw-r--r--Lib/test/test_unicode_file.py25
1 files changed, 6 insertions, 19 deletions
diff --git a/Lib/test/test_unicode_file.py b/Lib/test/test_unicode_file.py
index 4bafd98..6d7dec5 100644
--- a/Lib/test/test_unicode_file.py
+++ b/Lib/test/test_unicode_file.py
@@ -4,24 +4,13 @@
import os, glob
from test.test_support import verify, TestSkipped, TESTFN_UNICODE
+from test.test_support import TESTFN_ENCODING
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)
+ 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.
f = open(TESTFN_UNICODE, 'wb')
@@ -104,5 +93,3 @@ finally:
os.chdir(cwd)
os.rmdir(abs_encoded)
print "All the Unicode tests appeared to work"
-if oldlocale:
- locale.setlocale(locale.LC_CTYPE, oldlocale)