[Python-checkins] python/dist/src/Lib/test test_textwrap.py, 1.24,
1.25
gward at users.sourceforge.net
gward at users.sourceforge.net
Wed May 12 21:53:14 EDT 2004
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5197/Lib/test
Modified Files:
test_textwrap.py
Log Message:
SF #847346: merge from release23-maint branch: remove misguided
optimization for short input; beef up tests for fix_sentence_endings
feature.
Index: test_textwrap.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_textwrap.py,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** test_textwrap.py 17 Sep 2003 05:50:59 -0000 1.24
--- test_textwrap.py 13 May 2004 01:53:08 -0000 1.25
***************
*** 48,52 ****
def setUp(self):
! self.wrapper = TextWrapper(width=45, fix_sentence_endings=True)
def test_simple(self):
--- 48,52 ----
def setUp(self):
! self.wrapper = TextWrapper(width=45)
def test_simple(self):
***************
*** 85,95 ****
"mess!"]
! result = self.wrapper.wrap(text)
self.check(result, expect)
! result = self.wrapper.fill(text)
self.check(result, '\n'.join(expect))
def test_wrap_short(self):
# Wrapping to make short lines longer
--- 85,133 ----
"mess!"]
! wrapper = TextWrapper(45, fix_sentence_endings=True)
! result = wrapper.wrap(text)
self.check(result, expect)
! result = wrapper.fill(text)
self.check(result, '\n'.join(expect))
+ def test_fix_sentence_endings(self):
+ wrapper = TextWrapper(60, fix_sentence_endings=True)
+
+ # SF #847346: ensure that fix_sentence_endings=True does the
+ # right thing even on input short enough that it doesn't need to
+ # be wrapped.
+ text = "A short line. Note the single space."
+ expect = ["A short line. Note the single space."]
+ self.check(wrapper.wrap(text), expect)
+
+ # Test some of the hairy end cases that _fix_sentence_endings()
+ # is supposed to handle (the easy stuff is tested in
+ # test_whitespace() above).
+ text = "Well, Doctor? What do you think?"
+ expect = ["Well, Doctor? What do you think?"]
+ self.check(wrapper.wrap(text), expect)
+
+ text = "Well, Doctor?\nWhat do you think?"
+ self.check(wrapper.wrap(text), expect)
+
+ text = 'I say, chaps! Anyone for "tennis?"\nHmmph!'
+ expect = ['I say, chaps! Anyone for "tennis?" Hmmph!']
+ self.check(wrapper.wrap(text), expect)
+
+ wrapper.width = 20
+ expect = ['I say, chaps!', 'Anyone for "tennis?"', 'Hmmph!']
+ self.check(wrapper.wrap(text), expect)
+
+ text = 'And she said, "Go to hell!"\nCan you believe that?'
+ expect = ['And she said, "Go to',
+ 'hell!" Can you',
+ 'believe that?']
+ self.check(wrapper.wrap(text), expect)
+ wrapper.width = 60
+ expect = ['And she said, "Go to hell!" Can you believe that?']
+ self.check(wrapper.wrap(text), expect)
+
def test_wrap_short(self):
# Wrapping to make short lines longer
More information about the Python-checkins
mailing list