Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 269b3ce

Browse files
committed
(Merge 3.2) Issue #16218, #16414, #16444: Backport FS_NONASCII,
TESTFN_UNDECODABLE, TESTFN_NONASCII of test.support from Python 3.4. Backport tests on non-ASCII paths.
2 parents 7ae320d + 0af71aa commit 269b3ce

3 files changed

Lines changed: 18 additions & 15 deletions

File tree

Lib/test/support.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,9 @@ def _is_ipv6_enabled():
710710
b'\xae\xd5'
711711
# undecodable from UTF-8 (UNIX and Mac OS X)
712712
b'\xed\xb2\x80', b'\xed\xb4\x80',
713+
# undecodable from shift_jis, cp869, cp874, cp932, cp1250, cp1251, cp1252,
714+
# cp1253, cp1254, cp1255, cp1257, cp1258
715+
b'\x81\x98',
713716
):
714717
try:
715718
name.decode(TESTFN_ENCODING)

Lib/test/test_cmd_line_script.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,10 @@ def test_non_ascii(self):
367367
# Mac OS X denies the creation of a file with an invalid UTF-8 name.
368368
# Windows allows to create a name with an arbitrary bytes name, but
369369
# Python cannot a undecodable bytes argument to a subprocess.
370-
#if (support.TESTFN_UNDECODABLE
371-
#and sys.platform not in ('win32', 'darwin')):
372-
# name = os.fsdecode(support.TESTFN_UNDECODABLE)
373-
#elif support.TESTFN_NONASCII:
374-
if support.TESTFN_NONASCII:
370+
if (support.TESTFN_UNDECODABLE
371+
and sys.platform not in ('win32', 'darwin')):
372+
name = os.fsdecode(support.TESTFN_UNDECODABLE)
373+
elif support.TESTFN_NONASCII:
375374
name = support.TESTFN_NONASCII
376375
else:
377376
self.skipTest("need support.TESTFN_NONASCII")

Lib/test/test_genericpath.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -308,17 +308,18 @@ def test_abspath_issue3426(self):
308308
for path in ('', 'fuu', 'f\xf9\xf9', '/fuu', 'U:\\'):
309309
self.assertIsInstance(abspath(path), str)
310310

311-
@unittest.skipIf(sys.platform == 'darwin',
312-
"Mac OS X denies the creation of a directory with an invalid utf8 name")
313311
def test_nonascii_abspath(self):
314-
name = b'\xe7w\xf0'
315-
if sys.platform == 'win32':
316-
try:
317-
os.fsdecode(name)
318-
except UnicodeDecodeError:
319-
self.skipTest("the filename %a is not decodable "
320-
"from the ANSI code page %s"
321-
% (name, sys.getfilesystemencoding()))
312+
if (support.TESTFN_UNDECODABLE
313+
# Mac OS X denies the creation of a directory with an invalid
314+
# UTF-8 name. Windows allows to create a directory with an
315+
# arbitrary bytes name, but fails to enter this directory
316+
# (when the bytes name is used).
317+
and sys.platform not in ('win32', 'darwin')):
318+
name = support.TESTFN_UNDECODABLE
319+
elif support.TESTFN_NONASCII:
320+
name = support.TESTFN_NONASCII
321+
else:
322+
self.skipTest("need support.TESTFN_NONASCII")
322323

323324
# Test non-ASCII, non-UTF8 bytes in the path.
324325
with warnings.catch_warnings():

0 commit comments

Comments
 (0)