[py-svn] r38140 - in py/trunk/py/rest: . testing

guido at codespeak.net guido at codespeak.net
Thu Feb 8 13:26:04 CET 2007


Author: guido
Date: Thu Feb  8 13:26:02 2007
New Revision: 38140

Modified:
   py/trunk/py/rest/rst.py
   py/trunk/py/rest/testing/test_rst.py
Log:
Empty literal blocks are not allowed: removing them.


Modified: py/trunk/py/rest/rst.py
==============================================================================
--- py/trunk/py/rest/rst.py	(original)
+++ py/trunk/py/rest/rst.py	Thu Feb  8 13:26:02 2007
@@ -133,7 +133,8 @@
         for child in self.children:
             outcome.append(child.text())
         
-        text = self.sep.join(outcome) + "\n" # trailing newline
+        # always a trailing newline
+        text = self.sep.join([i for i in outcome if i]) + "\n"
         return text + self.render_links()
 
 class Transition(AbstractNode):
@@ -251,6 +252,8 @@
     start = '::\n\n'
 
     def text(self):
+        if not self._text.strip():
+            return ''
         text = self.escape(self._text).split('\n')
         for i, line in py.builtin.enumerate(text):
             if line.strip():

Modified: py/trunk/py/rest/testing/test_rst.py
==============================================================================
--- py/trunk/py/rest/testing/test_rst.py	(original)
+++ py/trunk/py/rest/testing/test_rst.py	Thu Feb  8 13:26:02 2007
@@ -175,6 +175,17 @@
     assert txt == expected
     checkrest(txt)
 
+def test_blockquote_empty():
+    expected = """\
+Foo
+
+Bar
+"""
+    txt = Rest(Paragraph('Foo'), LiteralBlock(''), Paragraph('Bar')).text()
+    print repr(txt)
+    assert txt == expected
+    checkrest(txt)
+
 def test_title():
     txt = Title(Text("Some title"), belowchar="=").text()
     assert txt == "Some title\n=========="



More information about the pytest-commit mailing list