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)
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)
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)
'item': 'j' }] } } } CNF_0_S = to_bytes("""\ <?xml version="1.0" encoding="UTF-8"?> <config xmlns="http://example.com/ns/cnf" xmlns:val="http://example.com/ns/cnf/val" val:name='foo'> <val:a>0</val:a> <val:b id="b0">bbb</val:b> <val:c/> <sect0> <val:d>x, y, z</val:d> </sect0> <list1> <item>0</item> <item>1</item> <item>2</item> </list1> <list2 id="list2"> <item>i</item> <item>j</item> </list2> </config> """) class Test_00(unittest.TestCase): def test_10__namespaces_from_file(self): ref = {
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)
class HasParserTrait(TBC.HasParserTrait): psr = TT.Parser() cnf = CNF_0 cnf_s = to_bytes(TBC.read_from_res("20-10-cnf.xml"))