[Python-checkins] python/dist/src/Lib/test test_textwrap.py,1.17,1.18

gward@users.sourceforge.net gward@users.sourceforge.net
Mon, 09 Dec 2002 08:32:44 -0800


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

Modified Files:
	test_textwrap.py 
Log Message:
Add test_unicode() to ensure that 1) textwrap doesn't crash on unicode
input, and 2) unicode input means unicode output.  This closes
SF bug #622831.


Index: test_textwrap.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_textwrap.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** test_textwrap.py	9 Dec 2002 16:27:15 -0000	1.17
--- test_textwrap.py	9 Dec 2002 16:32:41 -0000	1.18
***************
*** 240,243 ****
--- 240,255 ----
                          [" This is a sentence with", "leading whitespace."])
  
+     def test_unicode(self):
+         # *Very* simple test of wrapping Unicode strings.  I'm sure
+         # there's more to it than this, but let's at least make
+         # sure textwrap doesn't crash on Unicode input!
+         text = u"Hello there, how are you today?"
+         self.check_wrap(text, 50, [u"Hello there, how are you today?"])
+         self.check_wrap(text, 20, [u"Hello there, how are", "you today?"])
+         olines = self.wrapper.wrap(text)
+         assert isinstance(olines, list) and isinstance(olines[0], unicode)
+         otext = self.wrapper.fill(text)
+         assert isinstance(otext, unicode)
+ 
      def test_split(self):
          # Ensure that the standard _split() method works as advertised