[svn r37434] 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. --HG-- branch : trunk
This commit is contained in:
		
							parent
							
								
									f1b4e14f09
								
							
						
					
					
						commit
						58079397a2
					
				| 
						 | 
					@ -79,6 +79,7 @@ class AbstractNode(object):
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            returns a reference to the child
 | 
					            returns a reference to the child
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
 | 
					        self._add(child)
 | 
				
			||||||
        return child
 | 
					        return child
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
    def _add(self, child):
 | 
					    def _add(self, child):
 | 
				
			||||||
| 
						 | 
					@ -349,7 +350,8 @@ class Link(AbstractText):
 | 
				
			||||||
        if self.rest is None:
 | 
					        if self.rest is None:
 | 
				
			||||||
            self.rest = self.find_rest()
 | 
					            self.rest = self.find_rest()
 | 
				
			||||||
        if self.rest.links.get(self._text, self.target) != self.target:
 | 
					        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
 | 
					        self.rest.links[self._text] = self.target
 | 
				
			||||||
        return AbstractText.text(self)
 | 
					        return AbstractText.text(self)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -88,7 +88,7 @@ def test_basic_inline_2():
 | 
				
			||||||
    txt = Strong('bar').text()
 | 
					    txt = Strong('bar').text()
 | 
				
			||||||
    assert txt == '**bar**'
 | 
					    assert txt == '**bar**'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_text_join():
 | 
					def test_text_multiple_arguments():
 | 
				
			||||||
    txt = Paragraph(Text("dupa"), Text("dupa")).text()
 | 
					    txt = Paragraph(Text("dupa"), Text("dupa")).text()
 | 
				
			||||||
    assert txt == "dupa dupa"
 | 
					    assert txt == "dupa dupa"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -97,6 +97,12 @@ def test_text_join():
 | 
				
			||||||
    txt = txt.join(Text("happen at sea"), Text("you know"))
 | 
					    txt = txt.join(Text("happen at sea"), Text("you know"))
 | 
				
			||||||
    assert txt.text() == "worse things happen at sea 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():
 | 
					def test_paragraph_basic():
 | 
				
			||||||
    txt = Paragraph(Text('spam')).text()
 | 
					    txt = Paragraph(Text('spam')).text()
 | 
				
			||||||
    assert txt == 'spam'
 | 
					    assert txt == 'spam'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue