diff options
author | Walter Dörwald <walter@livinglogic.de> | 2007-06-08 14:30:53 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2007-06-08 14:30:53 (GMT) |
commit | 9b775535f828bedc30f3f52a04afec049b6aa25a (patch) | |
tree | 12b9a0e80636c157457d827a7436e77d843e03b3 /Lib/test/test_support.py | |
parent | 0157ebe999e951a4a3a5296586b08f4f96384bb3 (diff) | |
download | cpython-9b775535f828bedc30f3f52a04afec049b6aa25a.zip cpython-9b775535f828bedc30f3f52a04afec049b6aa25a.tar.gz cpython-9b775535f828bedc30f3f52a04afec049b6aa25a.tar.bz2 |
Rename checks for test_support.have_unicode (we always
have unicode support now) and either drop the tests or
merge them into the existing tests.
Diffstat (limited to 'Lib/test/test_support.py')
-rw-r--r-- | Lib/test/test_support.py | 63 |
1 files changed, 28 insertions, 35 deletions
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py index 5692a83..6a1fa86 100644 --- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -146,42 +146,35 @@ elif os.name == 'riscos': TESTFN = 'testfile' else: TESTFN = '@test' - # Unicode name only used if TEST_FN_ENCODING exists for the platform. - if have_unicode: - # Assuming sys.getfilesystemencoding()!=sys.getdefaultencoding() - # TESTFN_UNICODE is a filename that can be encoded using the - # file system encoding, but *not* with the default (ascii) encoding - if isinstance('', str): - # python -U - # XXX perhaps unicode() should accept Unicode strings? - TESTFN_UNICODE = "@test-\xe0\xf2" - else: - # 2 latin characters. - TESTFN_UNICODE = str("@test-\xe0\xf2", "latin-1") - 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. - # 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): # 0=win32s or 1=9x/ME - TESTFN_UNICODE_UNENCODEABLE = None + + # Assuming sys.getfilesystemencoding()!=sys.getdefaultencoding() + # TESTFN_UNICODE is a filename that can be encoded using the + # file system encoding, but *not* with the default (ascii) encoding + TESTFN_UNICODE = "@test-\xe0\xf2" + 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. + # 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): # 0=win32s or 1=9x/ME + TESTFN_UNICODE_UNENCODEABLE = None + else: + # Japanese characters (I think - from bug 846133) + TESTFN_UNICODE_UNENCODEABLE = "@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: - # Japanese characters (I think - from bug 846133) - TESTFN_UNICODE_UNENCODEABLE = eval('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) + 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 |