Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(13)

Side by Side Diff: Lib/test/test_unicode.py

Issue 767: [issue2630] repr() should not escape non-ASCII characters (Closed) SVN Base: http://svn.python.org/view/*checkout*/python/branches/py3k/
Patch Set: Created 1 year, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 # -*- coding: iso-8859-1 -*- 1 # -*- coding: iso-8859-1 -*-
2 """ Test script for the Unicode implementation. 2 """ Test script for the Unicode implementation.
3 3
4 Written by Marc-Andre Lemburg (mal@lemburg.com). 4 Written by Marc-Andre Lemburg (mal@lemburg.com).
5 5
6 (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. 6 (c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
7 7
8 """#" 8 """#"
9 import codecs 9 import codecs
10 import struct 10 import struct
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 self.assertEqual(repr("'\""), """'\\'"'""") 87 self.assertEqual(repr("'\""), """'\\'"'""")
88 self.assertEqual(repr("'"), '''"'"''') 88 self.assertEqual(repr("'"), '''"'"''')
89 self.assertEqual(repr('"'), """'"'""") 89 self.assertEqual(repr('"'), """'"'""")
90 latin1repr = ( 90 latin1repr = (
91 "'\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\t\\n\\x0b\\x0c\ \r" 91 "'\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\t\\n\\x0b\\x0c\ \r"
92 "\\x0e\\x0f\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x 1a" 92 "\\x0e\\x0f\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x 1a"
93 "\\x1b\\x1c\\x1d\\x1e\\x1f !\"#$%&\\'()*+,-./0123456789:;<=>?@AB CDEFGHI" 93 "\\x1b\\x1c\\x1d\\x1e\\x1f !\"#$%&\\'()*+,-./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d5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1"
102 "\\xe2\\xe3\\xe4\\xe5\\xe6\\xe7\\xe8\\xe9\\xea\\xeb\\xec\\xed\\x ee\\xef" 102 "\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
103 "\\xf0\\xf1\\xf2\\xf3\\xf4\\xf5\\xf6\\xf7\\xf8\\xf9\\xfa\\xfb\\x fc\\xfd" 103 "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd"
104 "\\xfe\\xff'") 104 "\xfe\xff'")
105 testrepr = repr(''.join(map(chr, range(256)))) 105 testrepr = repr(''.join(map(chr, range(256))))
106 self.assertEqual(testrepr, latin1repr) 106 self.assertEqual(testrepr, latin1repr)
107 # Test repr works on wide unicode escapes without overflow. 107 # Test repr works on wide unicode escapes without overflow.
108 self.assertEqual(repr("\U00010000" * 39 + "\uffff" * 4096), 108 self.assertEqual(repr("\U00010000" * 39 + "\uffff" * 4096),
109 repr("\U00010000" * 39 + "\uffff" * 4096)) 109 repr("\U00010000" * 39 + "\uffff" * 4096))
110 110
111 def test_iterators(self): 111 def test_iterators(self):
112 # Make sure unicode objects have an __iter__ method 112 # Make sure unicode objects have an __iter__ method
113 it = "\u1111\u2222\u3333".__iter__() 113 it = "\u1111\u2222\u3333".__iter__()
114 self.assertEqual(next(it), "\u1111") 114 self.assertEqual(next(it), "\u1111")
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 if sys.maxsize > (1 << 32) or struct.calcsize('P') != 4: 1074 if sys.maxsize > (1 << 32) or struct.calcsize('P') != 4:
1075 return 1075 return
1076 self.assertRaises(OverflowError, 't\tt\t'.expandtabs, sys.maxsize) 1076 self.assertRaises(OverflowError, 't\tt\t'.expandtabs, sys.maxsize)
1077 1077
1078 1078
1079 def test_main(): 1079 def test_main():
1080 test_support.run_unittest(__name__) 1080 test_support.run_unittest(__name__)
1081 1081
1082 if __name__ == "__main__": 1082 if __name__ == "__main__":
1083 test_main() 1083 test_main()
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld r497