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

guido at codespeak.net guido at codespeak.net
Sat Jan 27 15:11:55 CET 2007


Author: guido
Date: Sat Jan 27 15:11:52 2007
New Revision: 37434

Modified:
   py/trunk/py/rest/rst.py
   py/trunk/py/rest/testing/test_rst.py
Log:
Fixed bug in add() that made that the to-be-added item didn't get added (and
yes, I've added a test now ): ), made some error message a bit clearer.


Modified: py/trunk/py/rest/rst.py
==============================================================================
--- py/trunk/py/rest/rst.py	(original)
+++ py/trunk/py/rest/rst.py	Sat Jan 27 15:11:52 2007
@@ -79,6 +79,7 @@
             
             returns a reference to the child
         """
+        self._add(child)
         return child
         
     def _add(self, child):
@@ -349,7 +350,8 @@
         if self.rest is None:
             self.rest = self.find_rest()
         if self.rest.links.get(self._text, self.target) != self.target:
-            raise ValueError('link name already in use for a different target')
+            raise ValueError('link name %r already in use for a different '
+                             'target' % (self.target,))
         self.rest.links[self._text] = self.target
         return AbstractText.text(self)
 

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	Sat Jan 27 15:11:52 2007
@@ -88,7 +88,7 @@
     txt = Strong('bar').text()
     assert txt == '**bar**'
 
-def test_text_join():
+def test_text_multiple_arguments():
     txt = Paragraph(Text("dupa"), Text("dupa")).text()
     assert txt == "dupa dupa"
 
@@ -97,6 +97,12 @@
     txt = txt.join(Text("happen at sea"), Text("you know"))
     assert txt.text() == "worse things happen at sea you know"
 
+def test_text_add():
+    p = Paragraph(Text('grmbl'))
+    p2 = p.add(Text('grmbl too'))
+    assert p2.text() == 'grmbl too'
+    assert p.text() == 'grmbl grmbl too'
+
 def test_paragraph_basic():
     txt = Paragraph(Text('spam')).text()
     assert txt == 'spam'



More information about the pytest-commit mailing list