From: Victor Stinner Date: Wed, 1 Aug 2012 18:03:49 +0000 (+0200) Subject: Issue #15441: Skip test_nonascii_abspath() of test_genericpath on Windows X-Git-Tag: v3.3.0b2~69 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7c7ea62e6c20ed3a91dbac1ea922141975d0100f;p=thirdparty%2FPython%2Fcpython.git 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 --- diff --git a/Lib/test/test_genericpath.py b/Lib/test/test_genericpath.py index fc3d44c589e4..3eadd5893c4c 100644 --- a/Lib/test/test_genericpath.py +++ b/Lib/test/test_genericpath.py @@ -299,8 +299,7 @@ class CommonTest(GenericTest): unicwd = '\xe7w\xf0' try: - fsencoding = support.TESTFN_ENCODING or "ascii" - unicwd.encode(fsencoding) + os.fsencode(unicwd) except (AttributeError, UnicodeEncodeError): # FS encoding is probably ASCII pass @@ -312,10 +311,19 @@ class CommonTest(GenericTest): @unittest.skipIf(sys.platform == 'darwin', "Mac OS X denies the creation of a directory with an invalid utf8 name") def test_nonascii_abspath(self): + name = b'\xe7w\xf0' + if sys.platform == 'win32': + try: + os.fsdecode(name) + except UnicodeDecodeError: + self.skipTest("the filename %a is not decodable " + "from the ANSI code page %s" + % (name, sys.getfilesystemencoding())) + # Test non-ASCII, non-UTF8 bytes in the path. with warnings.catch_warnings(): warnings.simplefilter("ignore", DeprecationWarning) - with support.temp_cwd(b'\xe7w\xf0'): + with support.temp_cwd(name): self.test_abspath()