summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorMark Hammond <mhammond@skippinet.com.au>2003-12-03 22:16:47 (GMT)
committerMark Hammond <mhammond@skippinet.com.au>2003-12-03 22:16:47 (GMT)
commit2e8624c21ad0808bad02a2cf907d9a266f9c99d8 (patch)
treee2be9b0c72f723fab3b69c1ba202b90707cc9011 /Lib/test
parent07f1dfa91cd74fbdad9f88ea6aa80249cd0ada14 (diff)
downloadcpython-2e8624c21ad0808bad02a2cf907d9a266f9c99d8.zip
cpython-2e8624c21ad0808bad02a2cf907d9a266f9c99d8.tar.gz
cpython-2e8624c21ad0808bad02a2cf907d9a266f9c99d8.tar.bz2
Fix test_unicode_file errors on platforms without Unicode file support,
by setting TESTFN_UNICODE_UNENCODEABLE on these platforms. test_unicode_file only attempts to use the name for testing if not None.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_support.py36
-rw-r--r--Lib/test/test_unicode_file.py10
2 files changed, 27 insertions, 19 deletions
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
index b3f055a..9fcc049 100644
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -136,22 +136,28 @@ else:
TESTFN_ENCODING=sys.getfilesystemencoding()
# TESTFN_UNICODE_UNENCODEABLE is a filename that should *not* be
# able to be encoded by *either* the default or filesystem encoding.
- # Japanese characters (I think - from bug 846133)
- TESTFN_UNICODE_UNENCODEABLE = u"@test-\u5171\u6709\u3055\u308c\u308b"
- try:
- # XXX - Note - should be using TESTFN_ENCODING here - but for
- # Windows, "mbcs" currently always operates as if in
- # errors=ignore' mode - hence we get '?' characters rather than
- # the exception. 'Latin1' operates as we expect - ie, fails.
- # See [ 850997 ] mbcs encoding ignores errors
- TESTFN_UNICODE_UNENCODEABLE.encode("Latin1")
- except UnicodeEncodeError:
- pass
+ # This test really only makes sense on Windows NT platforms
+ # which have special Unicode support in posixmodule.
+ if not hasattr(sys, "getwindowsversion") or \
+ sys.getwindowsversion()[3]<2:
+ TESTFN_UNICODE_UNENCODABLE = None
else:
- print \
- 'WARNING: The filename %r CAN be encoded by the filesystem. ' \
- 'Unicode filename tests may not be effective' \
- % TESTFN_UNICODE_UNENCODEABLE
+ # Japanese characters (I think - from bug 846133)
+ TESTFN_UNICODE_UNENCODEABLE = u"@test-\u5171\u6709\u3055\u308c\u308b"
+ try:
+ # XXX - Note - should be using TESTFN_ENCODING here - but for
+ # Windows, "mbcs" currently always operates as if in
+ # errors=ignore' mode - hence we get '?' characters rather than
+ # the exception. 'Latin1' operates as we expect - ie, fails.
+ # See [ 850997 ] mbcs encoding ignores errors
+ TESTFN_UNICODE_UNENCODEABLE.encode("Latin1")
+ except UnicodeEncodeError:
+ pass
+ else:
+ print \
+ 'WARNING: The filename %r CAN be encoded by the filesystem. ' \
+ 'Unicode filename tests may not be effective' \
+ % TESTFN_UNICODE_UNENCODEABLE
# Make sure we can write to TESTFN, try in /tmp if we can't
fp = None
diff --git a/Lib/test/test_unicode_file.py b/Lib/test/test_unicode_file.py
index 467b78e..fbca88b 100644
--- a/Lib/test/test_unicode_file.py
+++ b/Lib/test/test_unicode_file.py
@@ -140,7 +140,8 @@ class TestUnicodeFiles(unittest.TestCase):
def test_single_files(self):
self._test_single(TESTFN_ENCODED)
self._test_single(TESTFN_UNICODE)
- self._test_single(TESTFN_UNICODE_UNENCODEABLE)
+ if TESTFN_UNICODE_UNENCODEABLE is not None:
+ self._test_single(TESTFN_UNICODE_UNENCODEABLE)
def test_equivalent_files(self):
self._test_equivalent(TESTFN_ENCODED, TESTFN_UNICODE)
@@ -156,9 +157,10 @@ class TestUnicodeFiles(unittest.TestCase):
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.
- self._do_directory(TESTFN_UNICODE_UNENCODEABLE+ext,
- TESTFN_UNICODE_UNENCODEABLE+ext,
- os.getcwdu)
+ if TESTFN_UNICODE_UNENCODEABLE is not None:
+ self._do_directory(TESTFN_UNICODE_UNENCODEABLE+ext,
+ TESTFN_UNICODE_UNENCODEABLE+ext,
+ os.getcwdu)
def test_main():
suite = unittest.TestSuite()