diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2012-11-06 22:23:43 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2012-11-06 22:23:43 (GMT) |
commit | 8b219b2936d767bf6c6c17618db3a7b22fc2e865 (patch) | |
tree | 717f4aa9f9aa97ffb916269572869b55018c831c /Lib/test/support.py | |
parent | df1d940c7c59398717a1b63d8681f26aeae48b87 (diff) | |
download | cpython-8b219b2936d767bf6c6c17618db3a7b22fc2e865.zip cpython-8b219b2936d767bf6c6c17618db3a7b22fc2e865.tar.gz cpython-8b219b2936d767bf6c6c17618db3a7b22fc2e865.tar.bz2 |
Issue #16414: Add support.FS_NONASCII and support.TESTFN_NONASCII
These constants are used to test functions with non-ASCII data, especially
filenames.
Diffstat (limited to 'Lib/test/support.py')
-rw-r--r-- | Lib/test/support.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Lib/test/support.py b/Lib/test/support.py index 93b94d9..4e946ab 100644 --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -603,6 +603,32 @@ else: # module name. TESTFN = "{}_{}_tmp".format(TESTFN, os.getpid()) +# FS_NONASCII: non-ASCII character encodable by os.fsencode(), +# or None if there is no such character. +FS_NONASCII = None +for character in ( + # U+00E6 (Latin small letter AE): Encodable to cp1252, cp1254, cp1257, iso-8859-1 + '\u00E6', + # U+0141 (Latin capital letter L with stroke): Encodable to cp1250, cp1257 + '\u0141', + # U+041A (Cyrillic capital letter KA): Encodable to cp932, cp950, cp1251 + '\u041A', + # U+05D0 (Hebrew Letter Alef): Encodable to cp424, cp1255 + '\u05D0', + # U+06A9 (Arabic letter KEHEH): Encodable to cp1256 + '\u06A9', + # U+03A9 (Greek capital letter OMEGA): Encodable to cp932, cp950, cp1253 + '\u03A9', + # U+0E01 (Thai character KO KAI): Encodable to cp874 + '\u0E01', +): + try: + os.fsdecode(os.fsencode(character)) + except UnicodeError: + pass + else: + FS_NONASCII = character + break # TESTFN_UNICODE is a non-ascii filename TESTFN_UNICODE = TESTFN + "-\xe0\xf2\u0258\u0141\u011f" @@ -658,6 +684,11 @@ for name in (b'abc\xff', b'\xe7w\xf0'): TESTFN_UNDECODABLE = name break +if FS_NONASCII: + TESTFN_NONASCII = TESTFN + '- ' + FS_NONASCII +else: + TESTFN_NONASCII = None + # Save the initial cwd SAVEDCWD = os.getcwd() |