summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_sys.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-08-24 23:05:51 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-08-24 23:05:51 (GMT)
commitebe53a23c9edc8f01fa261f9ea8e358b1ad481a2 (patch)
tree691137c8a8ca89a5e12c519490fc75be22da0eca /Lib/test/test_sys.py
parent8515eaefda6348a72464805ff8d07041d16ab97d (diff)
downloadcpython-ebe53a23c9edc8f01fa261f9ea8e358b1ad481a2.zip
cpython-ebe53a23c9edc8f01fa261f9ea8e358b1ad481a2.tar.gz
cpython-ebe53a23c9edc8f01fa261f9ea8e358b1ad481a2.tar.bz2
Fix test_sys for FreeBSD, Solaris and Mac OS X
_Py_char2wchar() (mbctowcs) decodes b'\xff' to '\xff' on FreeBSD, Solaris and Mac OS X, even if the locale is C (and the locale encoding is ASCII). Patch test_undecodable_code() to support this output and document the two different kinds of outputs.
Diffstat (limited to 'Lib/test/test_sys.py')
-rw-r--r--Lib/test/test_sys.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index 294814d..dcd36be 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -511,10 +511,23 @@ class SysModuleTest(unittest.TestCase):
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
env=env)
stdout, stderr = p.communicate()
- pattern = b"Unable to decode the command from the command line:"
+ if p.returncode == 1:
+ # _Py_char2wchar() decoded b'\xff' as '\udcff' (b'\xff' is not
+ # decodable from ASCII) and run_command() failed on
+ # PyUnicode_AsUTF8String(). This is the expected behaviour on
+ # Linux.
+ pattern = b"Unable to decode the command from the command line:"
+ elif p.returncode == 0:
+ # _Py_char2wchar() decoded b'\xff' as '\xff' even if the locale is
+ # C and the locale encoding is ASCII. It occurs on FreeBSD, Solaris
+ # and Mac OS X.
+ pattern = b"'\\xff' "
+ # The output is followed by the encoding name, an alias to ASCII.
+ # Examples: "US-ASCII" or "646" (ISO 646, on Solaris).
+ else:
+ raise AssertionError("Unknown exit code: %s, output=%a" % (p.returncode, stdout))
if not stdout.startswith(pattern):
raise AssertionError("%a doesn't start with %a" % (stdout, pattern))
- self.assertEqual(p.returncode, 1)
def test_sys_flags(self):
self.assertTrue(sys.flags)