summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_sys.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-06-11 23:06:13 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-06-11 23:06:13 (GMT)
commit9a45a6b1c2158c988d1fc1964dadd64c3f3f80c6 (patch)
treecc06bc388ffb9ae0f773837ad486567559d8da3a /Lib/test/test_sys.py
parent19e65a3563188f4440dc16abe08a7dfb1e8224c7 (diff)
downloadcpython-9a45a6b1c2158c988d1fc1964dadd64c3f3f80c6.zip
cpython-9a45a6b1c2158c988d1fc1964dadd64c3f3f80c6.tar.gz
cpython-9a45a6b1c2158c988d1fc1964dadd64c3f3f80c6.tar.bz2
Issue #8965: Write more tests for sys.getfilesystemencoding()
Diffstat (limited to 'Lib/test/test_sys.py')
-rw-r--r--Lib/test/test_sys.py35
1 files changed, 24 insertions, 11 deletions
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index 8273a79..d55da62 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -863,21 +863,34 @@ class SizeofTest(unittest.TestCase):
# sys.flags
check(sys.flags, size(vh) + self.P * len(sys.flags))
- @unittest.skipUnless(sys.platform == 'darwin', "test specific to Mac OS X")
def test_getfilesystemencoding(self):
- # On Darwing FS encoding is always UTF-8
+ import codecs
+
+ def check_fsencoding(fs_encoding):
+ self.assertIsNotNone(fs_encoding)
+ if sys.platform == 'darwin':
+ self.assertEqual(fs_encoding, 'utf-8')
+ codecs.lookup(fs_encoding)
+
fs_encoding = sys.getfilesystemencoding()
- self.assertEqual(fs_encoding, 'utf-8')
+ check_fsencoding(fs_encoding)
# Even in C locale
- env = os.environ.copy()
- env['LANG'] = 'C'
- output = subprocess.check_output(
- [sys.executable, "-c",
- "import sys; print(sys.getfilesystemencoding())"],
- env=env)
- fs_encoding = output.rstrip()
- self.assertEqual(fs_encoding, b'utf-8')
+ try:
+ sys.executable.encode('ascii')
+ except UnicodeEncodeError:
+ # Python doesn't start with ASCII locale if its path is not ASCII,
+ # see issue #8611
+ pass
+ else:
+ env = os.environ.copy()
+ env['LANG'] = 'C'
+ output = subprocess.check_output(
+ [sys.executable, "-c",
+ "import sys; print(sys.getfilesystemencoding())"],
+ env=env)
+ fs_encoding = output.rstrip().decode('ascii')
+ check_fsencoding(fs_encoding)
def test_setfilesystemencoding(self):
old = sys.getfilesystemencoding()