[Python-checkins] python/dist/src/Lib/test test_userstring.py, 1.11, 1.12 string_tests.py, 1.37, 1.38

perky at users.sourceforge.net perky at users.sourceforge.net
Thu Jun 3 23:18:14 EDT 2004


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27384/Lib/test

Modified Files:
	test_userstring.py string_tests.py 
Log Message:
Add iswide() and width() method for UserString according as the
addition to unicode objects.


Index: test_userstring.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_userstring.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** test_userstring.py	1 May 2003 17:45:55 -0000	1.11
--- test_userstring.py	4 Jun 2004 03:18:12 -0000	1.12
***************
*** 12,16 ****
      string_tests.MixinStrUnicodeUserStringTest,
      string_tests.MixinStrStringUserStringTest,
!     string_tests.MixinStrUserStringTest
      ):
  
--- 12,17 ----
      string_tests.MixinStrUnicodeUserStringTest,
      string_tests.MixinStrStringUserStringTest,
!     string_tests.MixinStrUserStringTest,
!     string_tests.MixinUnicodeUserStringTest
      ):
  

Index: string_tests.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/string_tests.py,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -d -r1.37 -r1.38
*** string_tests.py	5 Jan 2004 00:29:51 -0000	1.37
--- string_tests.py	4 Jun 2004 03:18:12 -0000	1.38
***************
*** 696,697 ****
--- 696,722 ----
          self.checkraises(TypeError, 'xyz', 'decode', 42)
          self.checkraises(TypeError, 'xyz', 'encode', 42)
+ 
+ 
+ class MixinUnicodeUserStringTest:
+     # Additional tests that only work with
+     # unicode compatible object, i.e. unicode and UserString
+ 
+     def test_iswide(self):
+         self.checkequal(False, u'', 'iswide')
+         self.checkequal(False, u'\x1f', 'iswide') # Neutral
+         self.checkequal(False, u'\x20', 'iswide') # Narrow
+         self.checkequal(True, u'\u2329', 'iswide') # Wide
+         self.checkequal(False, u'\uff64', 'iswide') # Half
+         self.checkequal(True, u'\u3000', 'iswide') # Full
+         self.checkequal(False, u'\u2460', 'iswide') # Ambiguous
+         self.checkequal(True, u'\ud55c\uae00', 'iswide')
+         self.checkequal(False, u'\ud55c\u2606\uae00', 'iswide')
+ 
+     def test_width(self):
+         self.checkequal(0, u'', 'width')
+         self.checkequal(4, u'abcd', 'width')
+         self.checkequal(2, u'\u0187\u01c9', 'width')
+         self.checkequal(3, u'\u2460\u2329', 'width')
+         self.checkequal(3, u'\u2329\u2460', 'width')
+         self.checkequal(4, u'\ud55c\uae00', 'width')
+         self.checkequal(5, u'\ud55c\u2606\uae00', 'width')




More information about the Python-checkins mailing list