mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
StdoutTests.test_unicode(): avoid newlines to fix the test on windows
* Add also a test for utf-8 * Add some comments * Flush stdout for the buffer API tests
This commit is contained in:
parent
caafd77060
commit
3a68f91d43
1 changed files with 13 additions and 8 deletions
|
@ -639,18 +639,23 @@ class StdoutTests(unittest.TestCase):
|
||||||
"sys.stdout.flush()")
|
"sys.stdout.flush()")
|
||||||
self.assertEqual(stdout, expected)
|
self.assertEqual(stdout, expected)
|
||||||
|
|
||||||
check_message(u'\u20ac\n', "iso-8859-15", "\xa4\n")
|
# test the encoding
|
||||||
check_message(u'\u20ac\n', "utf-16-le", '\xac\x20\n\x00')
|
check_message(u'15\u20ac', "iso-8859-15", "15\xa4")
|
||||||
check_message(u'15\u20ac\n', "iso-8859-1:ignore", "15\n")
|
check_message(u'15\u20ac', "utf-8", '15\xe2\x82\xac')
|
||||||
check_message(u'15\u20ac\n', "iso-8859-1:replace", "15?\n")
|
check_message(u'15\u20ac', "utf-16-le", '1\x005\x00\xac\x20')
|
||||||
check_message(u'15\u20ac\n', "iso-8859-1:backslashreplace",
|
|
||||||
"15\\u20ac\n")
|
|
||||||
|
|
||||||
|
# test the error handler
|
||||||
|
check_message(u'15\u20ac', "iso-8859-1:ignore", "15")
|
||||||
|
check_message(u'15\u20ac', "iso-8859-1:replace", "15?")
|
||||||
|
check_message(u'15\u20ac', "iso-8859-1:backslashreplace", "15\\u20ac")
|
||||||
|
|
||||||
|
# test the buffer API
|
||||||
for objtype in ('buffer', 'bytearray'):
|
for objtype in ('buffer', 'bytearray'):
|
||||||
stdout = get_message('ascii',
|
stdout = get_message('ascii',
|
||||||
'import sys',
|
'import sys',
|
||||||
r'sys.stdout.write(%s("\xe9\n"))' % objtype)
|
r'sys.stdout.write(%s("\xe9"))' % objtype,
|
||||||
self.assertEqual(stdout, "\xe9\n")
|
'sys.stdout.flush()')
|
||||||
|
self.assertEqual(stdout, "\xe9")
|
||||||
|
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue