Skip to content

Commit 7c7ea62

Browse files
committed
Issue #15441: Skip test_nonascii_abspath() of test_genericpath on Windows
if the bytes filenames cannot be encoded from the file system (ANSI) code page
1 parent 53386d8 commit 7c7ea62

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

Lib/test/test_genericpath.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,7 @@ def test_abspath_issue3426(self):
299299

300300
unicwd = '\xe7w\xf0'
301301
try:
302-
fsencoding = support.TESTFN_ENCODING or "ascii"
303-
unicwd.encode(fsencoding)
302+
os.fsencode(unicwd)
304303
except (AttributeError, UnicodeEncodeError):
305304
# FS encoding is probably ASCII
306305
pass
@@ -312,10 +311,19 @@ def test_abspath_issue3426(self):
312311
@unittest.skipIf(sys.platform == 'darwin',
313312
"Mac OS X denies the creation of a directory with an invalid utf8 name")
314313
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()))
322+
315323
# Test non-ASCII, non-UTF8 bytes in the path.
316324
with warnings.catch_warnings():
317325
warnings.simplefilter("ignore", DeprecationWarning)
318-
with support.temp_cwd(b'\xe7w\xf0'):
326+
with support.temp_cwd(name):
319327
self.test_abspath()
320328

321329

0 commit comments

Comments
 (0)