diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-09-08 11:45:16 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-09-08 11:45:16 (GMT) |
commit | 3a68f91d43d4d5fd147916525cea13dee30ea975 (patch) | |
tree | 70f5920022e70934d5b351408fdb74328958a4d2 | |
parent | caafd770606aaae96a7d6ed3a128d054758939f9 (diff) | |
download | cpython-3a68f91d43d4d5fd147916525cea13dee30ea975.zip cpython-3a68f91d43d4d5fd147916525cea13dee30ea975.tar.gz cpython-3a68f91d43d4d5fd147916525cea13dee30ea975.tar.bz2 |
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
-rw-r--r-- | Lib/test/test_file2k.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/Lib/test/test_file2k.py b/Lib/test/test_file2k.py index 7b9f9de..ebfd9e7 100644 --- a/Lib/test/test_file2k.py +++ b/Lib/test/test_file2k.py @@ -639,18 +639,23 @@ class StdoutTests(unittest.TestCase): "sys.stdout.flush()") self.assertEqual(stdout, expected) - check_message(u'\u20ac\n', "iso-8859-15", "\xa4\n") - check_message(u'\u20ac\n', "utf-16-le", '\xac\x20\n\x00') - check_message(u'15\u20ac\n', "iso-8859-1:ignore", "15\n") - check_message(u'15\u20ac\n', "iso-8859-1:replace", "15?\n") - check_message(u'15\u20ac\n', "iso-8859-1:backslashreplace", - "15\\u20ac\n") + # test the encoding + check_message(u'15\u20ac', "iso-8859-15", "15\xa4") + check_message(u'15\u20ac', "utf-8", '15\xe2\x82\xac') + check_message(u'15\u20ac', "utf-16-le", '1\x005\x00\xac\x20') + # 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'): stdout = get_message('ascii', 'import sys', - r'sys.stdout.write(%s("\xe9\n"))' % objtype) - self.assertEqual(stdout, "\xe9\n") + r'sys.stdout.write(%s("\xe9"))' % objtype, + 'sys.stdout.flush()') + self.assertEqual(stdout, "\xe9") def test_main(): |