Beispiel #1
0
 def test_22_container_to_etree__children(self):
     ref = to_bytes("<a><b>b</b><c>c</c></a>")
     obj = {'a': {'@children': [{'b': 'b'}, {'c': 'c'}]}}
     res = TT.container_to_etree(obj)
     self.assertEqual(tree_to_string(res), ref)
Beispiel #2
0
 def test_12_container_to_etree__text_attrs_tags(self):
     ref = to_bytes('<a x="X" y="Y">A</a>')
     obj = dict(a={"_attrs": {'x': 'X', 'y': 'Y'}, "_text": "A"})
     tags = dict(attrs="_attrs", text="_text")
     res = TT.container_to_etree(obj, tags=tags)
     self.assertEqual(tree_to_string(res), ref)
Beispiel #3
0
 def test_20_container_to_etree__child(self):
     ref = to_bytes("<a><b>b</b></a>")
     obj = dict(a=dict(b="b"))
     res = TT.container_to_etree(obj)
     self.assertEqual(tree_to_string(res), ref)
Beispiel #4
0
 def test_00_container_to_etree__None(self):
     self.assertTrue(TT.container_to_etree(None) is None)
Beispiel #5
0
 def test_10_container_to_etree__text_attrs(self):
     ref = to_bytes('<a x="X" y="Y">A</a>')
     obj = dict(a={"@attrs": {'x': 'X', 'y': 'Y'}, "@text": "A"})
     res = TT.container_to_etree(obj)
     self.assertEqual(tree_to_string(res), ref)
Beispiel #6
0
 def test_20_container_to_etree__empty(self):
     # This should not happen but just in case.
     self.assertTrue(TT.container_to_etree("aaa", dict) is None)
Beispiel #7
0
 def test_22_container_to_etree(self):
     tree = TT.container_to_etree(self.cnf, to_container)
     buf = TT.BytesIO()
     tree.write(buf)
     cnf_s = buf.getvalue()
     self.assertEqual(cnf_s, self.cnf_s, cnf_s)
Beispiel #8
0
 def test_22_container_to_etree__children(self):
     ref = to_bytes("<a><b>b</b><c>c</c></a>")
     obj = {'a': {'@children': [{'b': 'b'}, {'c': 'c'}]}}
     res = TT.container_to_etree(obj)
     self.assertEqual(tree_to_string(res), ref)
Beispiel #9
0
 def test_20_container_to_etree__child(self):
     ref = to_bytes("<a><b>b</b></a>")
     obj = dict(a=dict(b="b"))
     res = TT.container_to_etree(obj)
     self.assertEqual(tree_to_string(res), ref)
Beispiel #10
0
 def test_12_container_to_etree__text_attrs_tags(self):
     ref = to_bytes('<a x="X" y="Y">A</a>')
     obj = dict(a={"_attrs": {'x': 'X', 'y': 'Y'}, "_text": "A"})
     tags = dict(attrs="_attrs", text="_text")
     res = TT.container_to_etree(obj, tags=tags)
     self.assertEqual(tree_to_string(res), ref)
Beispiel #11
0
 def test_10_container_to_etree__text_attrs(self):
     ref = to_bytes('<a x="X" y="Y">A</a>')
     obj = dict(a={"@attrs": {'x': 'X', 'y': 'Y'}, "@text": "A"})
     res = TT.container_to_etree(obj)
     self.assertEqual(tree_to_string(res), ref)
Beispiel #12
0
 def test_00_container_to_etree__None(self):
     self.assertTrue(TT.container_to_etree(None) is None)