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

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

Issue 9682: socket.create_connection error message for domain subpart with invalid length is very confusing
Patch Set: Created 7 years, 1 month ago
Left:
Right:
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
« Lib/encodings/idna.py ('K') | « Lib/encodings/idna.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """ Test script for the Unicode implementation. 1 """ Test script for the Unicode implementation.
2 2
3 Written by Marc-Andre Lemburg (mal@lemburg.com). 3 Written by Marc-Andre Lemburg (mal@lemburg.com).
4 4
5 (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. 5 (c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
6 6
7 """#" 7 """#"
8 import _string 8 import _string
9 import codecs 9 import codecs
10 import itertools 10 import itertools
(...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after
1665 ('F4 8F BF 00', FFFD+'\x00'), ('F4 8F BF 7F', FFFD+'\x7f'), 1665 ('F4 8F BF 00', FFFD+'\x00'), ('F4 8F BF 7F', FFFD+'\x7f'),
1666 ('F4 8F BF C0', FFFDx2), ('F4 8F BF FF', FFFDx2) 1666 ('F4 8F BF C0', FFFDx2), ('F4 8F BF FF', FFFDx2)
1667 ] 1667 ]
1668 for seq, res in sequences: 1668 for seq, res in sequences:
1669 self.assertCorrectUTF8Decoding(self.to_bytestring(seq), res, 1669 self.assertCorrectUTF8Decoding(self.to_bytestring(seq), res,
1670 'invalid continuation byte') 1670 'invalid continuation byte')
1671 1671
1672 def test_codecs_idna(self): 1672 def test_codecs_idna(self):
1673 # Test whether trailing dot is preserved 1673 # Test whether trailing dot is preserved
1674 self.assertEqual("www.python.org.".encode("idna"), b"www.python.org.") 1674 self.assertEqual("www.python.org.".encode("idna"), b"www.python.org.")
1675
r.david.murray 2013/04/13 21:49:49 Maximum line length should be 79 characters.
1676 def test_codecs_errors_messages(self):
1677 # Test Empty
1678 self.assertRaisesRegexp(UnicodeError, 'label empty or too long in 1..com ', "1..com".encode, 'idna')
r.david.murray 2013/04/13 21:49:49 The idea behind using assertRaisesRegex is to only
mmilkin 2013/04/13 23:16:53 My thought around testing for the full error was t
1679 # Test label greater then 64
1680 label = "A" * 64
1681 value = "first." + label + ".last"
1682 self.assertRaisesRegexp(UnicodeError, 'label empty or too long in first. %s.last' % label, value.encode, 'idna')
1683 # Test last label length 64
1684 value = "first.second." + label
1685 self.assertRaisesRegexp(UnicodeError, "label too long " + label, value.e ncode, 'idna')
1686 # Test last label length greater then 64
1687 label += "A"
1688 value += "A"
1689 self.assertRaisesRegexp(UnicodeError, "label too long " + label, value.e ncode, 'idna')
1675 1690
1676 def test_codecs_errors(self): 1691 def test_codecs_errors(self):
1677 # Error handling (encoding) 1692 # Error handling (encoding)
1678 self.assertRaises(UnicodeError, 'Andr\202 x'.encode, 'ascii') 1693 self.assertRaises(UnicodeError, 'Andr\202 x'.encode, 'ascii')
1679 self.assertRaises(UnicodeError, 'Andr\202 x'.encode, 'ascii','strict') 1694 self.assertRaises(UnicodeError, 'Andr\202 x'.encode, 'ascii','strict')
1680 self.assertEqual('Andr\202 x'.encode('ascii','ignore'), b"Andr x") 1695 self.assertEqual('Andr\202 x'.encode('ascii','ignore'), b"Andr x")
1681 self.assertEqual('Andr\202 x'.encode('ascii','replace'), b"Andr? x") 1696 self.assertEqual('Andr\202 x'.encode('ascii','replace'), b"Andr? x")
1682 self.assertEqual('Andr\202 x'.encode('ascii', 'replace'), 1697 self.assertEqual('Andr\202 x'.encode('ascii', 'replace'),
1683 'Andr\202 x'.encode('ascii', errors='replace')) 1698 'Andr\202 x'.encode('ascii', errors='replace'))
1684 self.assertEqual('Andr\202 x'.encode('ascii', 'ignore'), 1699 self.assertEqual('Andr\202 x'.encode('ascii', 'ignore'),
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
2340 "obj", 2355 "obj",
2341 [(True, 'arg'), 2356 [(True, 'arg'),
2342 (False, 'key1'), 2357 (False, 'key1'),
2343 (False, 'key2'), 2358 (False, 'key2'),
2344 ]]) 2359 ]])
2345 self.assertRaises(TypeError, _string.formatter_field_name_split, 1) 2360 self.assertRaises(TypeError, _string.formatter_field_name_split, 1)
2346 2361
2347 2362
2348 if __name__ == "__main__": 2363 if __name__ == "__main__":
2349 unittest.main() 2364 unittest.main()
OLDNEW
« Lib/encodings/idna.py ('K') | « Lib/encodings/idna.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+