Skip to content

Commit

Permalink
fix: add missing test cases to parse attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
ssato committed Feb 18, 2017
1 parent f9beda5 commit 0fd16df
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions anyconfig/backend/tests/xml.py
Expand Up @@ -118,6 +118,22 @@ def test_34__process_elem_attrs__merge_attrs(self):
self.assertTrue(dicts_equal(dic, {"a": {"id": 'A'}}))
self.assertTrue(not subdic)

def test_36__process_elem_attrs__wo_text_and_children_parse(self):
(elem, dic, subdic) = (TT.ET.XML("<a id='1'/>"), {}, {})
TT._process_elem_attrs(elem, dic, subdic, ac_parse_value=True)
self.assertTrue(not dic)
self.assertTrue(dicts_equal(subdic, {"@attrs": {"id": 1}}))

(elem, dic, subdic) = (TT.ET.XML("<a id='A'/>"), {}, {})
TT._process_elem_attrs(elem, dic, subdic, ac_parse_value=True)
self.assertTrue(not dic)
self.assertTrue(dicts_equal(subdic, {"@attrs": {"id": 'A'}}))

(elem, dic, subdic) = (TT.ET.XML("<a id='true'/>"), {}, {})
TT._process_elem_attrs(elem, dic, subdic, ac_parse_value=True)
self.assertTrue(not dic)
self.assertTrue(dicts_equal(subdic, {"@attrs": {"id": True}}))

def test_40__process_children_elems__root(self):
(elem, dic, subdic) = (TT.ET.XML("<list><i>A</i><i>B</i></list>"), {},
{})
Expand Down

0 comments on commit 0fd16df

Please sign in to comment.