[Python-checkins] python/dist/src/Lib/test test_unicode.py,1.79,1.80 test_str.py,1.1,1.2 string_tests.py,1.29,1.30

doerwalter@users.sourceforge.net doerwalter@users.sourceforge.net
Mon, 31 Mar 2003 10:07:58 -0800


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv22062/Lib/test

Modified Files:
	test_unicode.py test_str.py string_tests.py 
Log Message:
Fix PyString_Format() so that '%c' % u'a' returns u'a'
instead of raising a TypeError. (From SF patch #710127)

Add tests to verify this is fixed.

Add various tests for '%c' % int.


Index: test_unicode.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v
retrieving revision 1.79
retrieving revision 1.80
diff -C2 -d -r1.79 -r1.80
*** test_unicode.py	21 Feb 2003 12:53:49 -0000	1.79
--- test_unicode.py	31 Mar 2003 18:07:45 -0000	1.80
***************
*** 359,362 ****
--- 359,364 ----
          self.assertEqual(u"%(x)s, %(y)s" % {'x':u"abc", 'y':"def"}, u'abc, def')
          self.assertEqual(u"%(x)s, %(\xfc)s" % {'x':u"abc", u'\xfc':"def"}, u'abc, def')
+         self.assertEqual(u'%c' % 0x1234, u'\u1234')
+         self.assertRaises(ValueError, u'%c'.__mod__, sys.maxunicode+1)
  
          # formatting jobs delegated from the string implementation:
***************
*** 376,379 ****
--- 378,382 ----
          self.assertEqual('%i %*.*s' % (10, 5,3,u'abc',), u'10   abc')
          self.assertEqual('%i%s %*.*s' % (10, 3, 5, 3, u'abc',), u'103   abc')
+         self.assertEqual('%c' % u'a', u'a')
  
          self.assertRaises(ValueError, u"%c".__mod__, (sys.maxunicode+1,))

Index: test_str.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_str.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** test_str.py	21 Feb 2003 12:53:49 -0000	1.1
--- test_str.py	31 Mar 2003 18:07:49 -0000	1.2
***************
*** 15,18 ****
--- 15,22 ----
          return obj
  
+     def test_formatting(self):
+         string_tests.MixinStrUnicodeUserStringTest.test_formatting(self)
+         self.assertRaises(OverflowError, '%c'.__mod__, 0x1234)
+ 
  def test_main():
      suite = unittest.TestSuite()

Index: string_tests.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/string_tests.py,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** string_tests.py	26 Mar 2003 14:31:25 -0000	1.29
--- string_tests.py	31 Mar 2003 18:07:50 -0000	1.30
***************
*** 544,547 ****
--- 544,548 ----
          self.checkequal('$', "%c", '__mod__', 36)
          self.checkequal('10', "%d", '__mod__', 10)
+         self.checkequal('\x7f', "%c", '__mod__', 0x7f)
  
          for ordinal in (-100, 0x200000):