[Python-checkins] python/dist/src/Lib/test test_textwrap.py, 1.27, 1.28

gward at users.sourceforge.net gward at users.sourceforge.net
Sat Mar 5 03:53:20 CET 2005


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

Modified Files:
	test_textwrap.py 
Log Message:
SF #1149508: ensure textwrap handles hyphenated numbers correctly,
eg. "2004-03-04" is not broken across lines.  (Merged from 2.4 branch.)


Index: test_textwrap.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_textwrap.py,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- test_textwrap.py	8 Jul 2004 04:22:19 -0000	1.27
+++ test_textwrap.py	5 Mar 2005 02:53:17 -0000	1.28
@@ -165,6 +165,24 @@
                         ["this-is-a-useful-feature-for-reformatting-",
                          "posts-from-tim-peters'ly"])
 
+    def test_hyphenated_numbers(self):
+        # Test that hyphenated numbers (eg. dates) are not broken like words.
+        text = ("Python 1.0.0 was released on 1994-01-26.  Python 1.0.1 was\n"
+                "released on 1994-02-15.")
+
+        self.check_wrap(text, 30, ['Python 1.0.0 was released on',
+                                   '1994-01-26.  Python 1.0.1 was',
+                                   'released on 1994-02-15.'])
+        self.check_wrap(text, 40, ['Python 1.0.0 was released on 1994-01-26.',
+                                   'Python 1.0.1 was released on 1994-02-15.'])
+
+        text = "I do all my shopping at 7-11."
+        self.check_wrap(text, 25, ["I do all my shopping at",
+                                   "7-11."])
+        self.check_wrap(text, 27, ["I do all my shopping at",
+                                   "7-11."])
+        self.check_wrap(text, 29, ["I do all my shopping at 7-11."])
+
     def test_em_dash(self):
         # Test text with em-dashes
         text = "Em-dashes should be written -- thus."



More information about the Python-checkins mailing list