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

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

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months 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
« no previous file with comments | « Lib/test/test_unicode_file.py ('k') | Lib/test/test_urllib2net.py » ('j') | 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 codecs 8 import codecs
9 import struct 9 import struct
10 import sys 10 import sys
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 return spec 728 return spec
729 self.assertEqual('{foo._x}'.format_map({'foo': C(20)}), '20') 729 self.assertEqual('{foo._x}'.format_map({'foo': C(20)}), '20')
730 730
731 # test various errors 731 # test various errors
732 self.assertRaises(TypeError, '{'.format_map) 732 self.assertRaises(TypeError, '{'.format_map)
733 self.assertRaises(TypeError, '}'.format_map) 733 self.assertRaises(TypeError, '}'.format_map)
734 self.assertRaises(TypeError, 'a{'.format_map) 734 self.assertRaises(TypeError, 'a{'.format_map)
735 self.assertRaises(TypeError, 'a}'.format_map) 735 self.assertRaises(TypeError, 'a}'.format_map)
736 self.assertRaises(TypeError, '{a'.format_map) 736 self.assertRaises(TypeError, '{a'.format_map)
737 self.assertRaises(TypeError, '}a'.format_map) 737 self.assertRaises(TypeError, '}a'.format_map)
738
739 # issue #12579: can't supply positional params to format_map
740 self.assertRaises(ValueError, '{}'.format_map, {'a' : 2})
741 self.assertRaises(ValueError, '{}'.format_map, 'a')
742 self.assertRaises(ValueError, '{a} {}'.format_map, {"a" : 2, "b" : 1})
743 738
744 def test_format_auto_numbering(self): 739 def test_format_auto_numbering(self):
745 class C: 740 class C:
746 def __init__(self, x=100): 741 def __init__(self, x=100):
747 self._x = x 742 self._x = x
748 def __format__(self, spec): 743 def __format__(self, spec):
749 return spec 744 return spec
750 745
751 self.assertEqual('{}'.format(10), '10') 746 self.assertEqual('{}'.format(10), '10')
752 self.assertEqual('{:5}'.format('s'), 's ') 747 self.assertEqual('{:5}'.format('s'), 's ')
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 self.assertEqual("%a" % ("\u1234",), "'\\u1234'") 781 self.assertEqual("%a" % ("\u1234",), "'\\u1234'")
787 self.assertEqual("%(x)s, %(y)s" % {'x':"abc", 'y':"def"}, 'abc, def') 782 self.assertEqual("%(x)s, %(y)s" % {'x':"abc", 'y':"def"}, 'abc, def')
788 self.assertEqual("%(x)s, %(\xfc)s" % {'x':"abc", '\xfc':"def"}, 'abc, de f') 783 self.assertEqual("%(x)s, %(\xfc)s" % {'x':"abc", '\xfc':"def"}, 'abc, de f')
789 784
790 self.assertEqual('%c' % 0x1234, '\u1234') 785 self.assertEqual('%c' % 0x1234, '\u1234')
791 self.assertEqual('%c' % 0x21483, '\U00021483') 786 self.assertEqual('%c' % 0x21483, '\U00021483')
792 self.assertRaises(OverflowError, "%c".__mod__, (0x110000,)) 787 self.assertRaises(OverflowError, "%c".__mod__, (0x110000,))
793 self.assertEqual('%c' % '\U00021483', '\U00021483') 788 self.assertEqual('%c' % '\U00021483', '\U00021483')
794 self.assertRaises(TypeError, "%c".__mod__, "aa") 789 self.assertRaises(TypeError, "%c".__mod__, "aa")
795 self.assertRaises(ValueError, "%.1\u1032f".__mod__, (1.0/3)) 790 self.assertRaises(ValueError, "%.1\u1032f".__mod__, (1.0/3))
796 self.assertRaises(TypeError, "%i".__mod__, "aa")
797 791
798 # formatting jobs delegated from the string implementation: 792 # formatting jobs delegated from the string implementation:
799 self.assertEqual('...%(foo)s...' % {'foo':"abc"}, '...abc...') 793 self.assertEqual('...%(foo)s...' % {'foo':"abc"}, '...abc...')
800 self.assertEqual('...%(foo)s...' % {'foo':"abc"}, '...abc...') 794 self.assertEqual('...%(foo)s...' % {'foo':"abc"}, '...abc...')
801 self.assertEqual('...%(foo)s...' % {'foo':"abc"}, '...abc...') 795 self.assertEqual('...%(foo)s...' % {'foo':"abc"}, '...abc...')
802 self.assertEqual('...%(foo)s...' % {'foo':"abc"}, '...abc...') 796 self.assertEqual('...%(foo)s...' % {'foo':"abc"}, '...abc...')
803 self.assertEqual('...%(foo)s...' % {'foo':"abc",'def':123}, '...abc...' ) 797 self.assertEqual('...%(foo)s...' % {'foo':"abc",'def':123}, '...abc...' )
804 self.assertEqual('...%(foo)s...' % {'foo':"abc",'def':123}, '...abc...') 798 self.assertEqual('...%(foo)s...' % {'foo':"abc",'def':123}, '...abc...')
805 self.assertEqual('...%s...%s...%s...%s...' % (1,2,3,"abc"), '...1...2... 3...abc...') 799 self.assertEqual('...%s...%s...%s...%s...' % (1,2,3,"abc"), '...1...2... 3...abc...')
806 self.assertEqual('...%%...%%s...%s...%s...%s...%s...' % (1,2,3,"abc"), ' ...%...%s...1...2...3...abc...') 800 self.assertEqual('...%%...%%s...%s...%s...%s...%s...' % (1,2,3,"abc"), ' ...%...%s...1...2...3...abc...')
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
1635 (False, 'key2'), 1629 (False, 'key2'),
1636 ]]) 1630 ]])
1637 self.assertRaises(TypeError, _string.formatter_field_name_split, 1) 1631 self.assertRaises(TypeError, _string.formatter_field_name_split, 1)
1638 1632
1639 1633
1640 def test_main(): 1634 def test_main():
1641 support.run_unittest(__name__) 1635 support.run_unittest(__name__)
1642 1636
1643 if __name__ == "__main__": 1637 if __name__ == "__main__":
1644 test_main() 1638 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_unicode_file.py ('k') | Lib/test/test_urllib2net.py » ('j') | no next file with comments »

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