def _get_complex_structure(self): tree = Tree() tree.instruct('xml') #tree.cdata(r"<b>I am some text.</b>") tree.declare('DOCTYPE', __.author, __.SYSTEM, 'SomeDTD.dtd') with tree.node('author') as author: author.node('name', 'Terry Pratchett') author.node('genre', 'Fantasy/Comedy') author.comment("Only 2 books listed") with author.node('novels', count=2) as novels: novels.node('novel', 'Small Gods', year=1992) novels.node('novel', 'The Fifth Elephant', year=1999) return tree
def _get_complex_structure(self): tree = Tree() tree.instruct('xml') #tree.cdata(r"<b>I am some text.</b>") tree.declare('DOCTYPE', __.author, __.SYSTEM, 'SomeDTD.dtd') with tree.node('author') as author: author.node('name', 'Terry Pratchett') author.node('genre', 'Fantasy/Comedy') author.comment("Only 2 books listed") with author.node('novels', count=2) as novels: novels.node('novel', 'Small Gods', year=1992) novels.node('novel', 'The Fifth Elephant', year=1999) return tree
def test_render_instruction(self): tree = Tree() tree.instruct('process', do="Good") self.assertIn(tree(), '<?process do="Good"?>')
def test_render_instruction_xml(self): tree = Tree() tree.instruct('xml') self.assertIn(tree(), '<?xml version="1.0" encoding="UTF-8"?>')
def _get_test_tree(self): tree = Tree() tree.instruct() tree.node('name', 'Bob') tree.node('age', 12) return tree
def _get_test_tree(self): tree = Tree() tree.instruct() tree.node('name', 'Bob') tree.node('age', 12) return tree
def test_render_instruction(self): tree = Tree() tree.instruct('process', do="Good") self.assertIn(tree(), '<?process do="Good"?>')
def test_render_instruction_xml(self): tree = Tree() tree.instruct('xml') self.assertIn(tree(), '<?xml version="1.0" encoding="UTF-8"?>')