[py-svn] r33431 - in py/dist/py/rst: . testing

guido at codespeak.net guido at codespeak.net
Wed Oct 18 23:11:39 CEST 2006


Author: guido
Date: Wed Oct 18 23:11:38 2006
New Revision: 33431

Modified:
   py/dist/py/rst/rst.py
   py/dist/py/rst/testing/test_rst.py
Log:
Fixed whitespace stripping for paragraphs on non-string content.


Modified: py/dist/py/rst/rst.py
==============================================================================
--- py/dist/py/rst/rst.py	(original)
+++ py/dist/py/rst/rst.py	Wed Oct 18 23:11:38 2006
@@ -127,6 +127,9 @@
         texts.reverse()
         while texts:
             next = texts[-1]
+            if not next:
+                texts.pop()
+                continue
             if lgt + len(self.sep) + len(next) <= self.width or not buf:
                 buf.append(next)
                 lgt += len(next) + len(self.sep)

Modified: py/dist/py/rst/testing/test_rst.py
==============================================================================
--- py/dist/py/rst/testing/test_rst.py	(original)
+++ py/dist/py/rst/testing/test_rst.py	Wed Oct 18 23:11:38 2006
@@ -78,6 +78,11 @@
                          ).text()
     assert txt == expected
 
+def test_text_strip():
+    expected = "foo\n"
+    txt = Rest(Paragraph(Text(' foo '))).text()
+    assert txt == expected
+
 def test_list():
     expected = "* a\n\n* b\n"
     txt = Rest(ListItem("a"), ListItem("b")).text()



More information about the pytest-commit mailing list