summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Ward <gward@python.net>2002-08-22 21:16:25 (GMT)
committerGreg Ward <gward@python.net>2002-08-22 21:16:25 (GMT)
commit715debd3d1cba8aad84e3492854a3e7860557e86 (patch)
tree69bf785e0e0f7201ef719f850524fd78918ba992
parent24a1c9cff5025c6006d639a787ac789809380032 (diff)
downloadcpython-715debd3d1cba8aad84e3492854a3e7860557e86.zip
cpython-715debd3d1cba8aad84e3492854a3e7860557e86.tar.gz
cpython-715debd3d1cba8aad84e3492854a3e7860557e86.tar.bz2
Factored out BaseTestCase.check_split() method -- use it wherever
we need to test TextWrapper._split().
-rw-r--r--Lib/test/test_textwrap.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/Lib/test/test_textwrap.py b/Lib/test/test_textwrap.py
index 838596d..36df52a 100644
--- a/Lib/test/test_textwrap.py
+++ b/Lib/test/test_textwrap.py
@@ -37,6 +37,12 @@ class BaseTestCase(unittest.TestCase):
result = wrap(text, width)
self.check(result, expect)
+ def check_split (self, wrapper, text, expect):
+ result = wrapper._split(text)
+ self.assertEquals(result, expect,
+ "\nexpected %r\n"
+ "but got %r" % (expect, result))
+
class WrapTestCase(BaseTestCase):
@@ -155,13 +161,10 @@ What a mess!
# All of the above behaviour could be deduced by probing the
# _split() method.
text = "Here's an -- em-dash and--here's another---and another!"
- result = self.wrapper._split(text)
expect = ["Here's", " ", "an", " ", "--", " ", "em-", "dash", " ",
"and", "--", "here's", " ", "another", "---",
"and", " ", "another!"]
- self.assertEquals(result, expect,
- "\nexpected %r\n"
- "but got %r" % (expect, result))
+ self.check_split(self.wrapper, text, expect)
def test_unix_options (self):
# Test that Unix-style command-line options are wrapped correctly.
@@ -193,12 +196,9 @@ What a mess!
# Again, all of the above can be deduced from _split().
text = "the -n option, or --dry-run or --dryrun"
- result = self.wrapper._split(text)
expect = ["the", " ", "-n", " ", "option,", " ", "or", " ",
"--dry-", "run", " ", "or", " ", "--dryrun"]
- self.assertEquals(result, expect,
- "\nexpected %r\n"
- "but got %r" % (expect, result))
+ self.check_split(self.wrapper, text, expect)
def test_split(self):
# Ensure that the standard _split() method works as advertised