File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -96,5 +96,4 @@ def is_self_closed_tag(xml):
9696 return False
9797 if xml .text is not None :
9898 return False
99- data_type_string = etree .tostring (xml , pretty_print = True ).decode ("utf-8" )
100- return data_type_string .find (f"</{ xml .tag } >" ) == - 1
99+ return True
Original file line number Diff line number Diff line change 11from lxml import etree
22
3- from reqif .helpers .lxml import dump_xml_node , stringify_namespaced_children
3+ from reqif .helpers .lxml import (
4+ dump_xml_node ,
5+ is_self_closed_tag ,
6+ stringify_namespaced_children ,
7+ )
48
59
610def test_01_dump_xml () -> None :
@@ -45,3 +49,25 @@ def test__02_stringify_namespaced_children__02_nested_tags_and_attrs() -> None:
4549 string = stringify_namespaced_children (spec_type_xml )
4650
4751 assert string == expected_string
52+
53+
54+ def test__is_self_closed_tag () -> None :
55+ spec_type_string = """\
56+ <THE-VALUE>\
57+ Text
58+ </THE-VALUE>
59+ """
60+ spec_type_xml = etree .fromstring (spec_type_string )
61+ assert is_self_closed_tag (spec_type_xml ) is False
62+
63+ spec_type_string = """\
64+ <THE-VALUE></THE-VALUE>
65+ """
66+ spec_type_xml = etree .fromstring (spec_type_string )
67+ assert is_self_closed_tag (spec_type_xml ) is True
68+
69+ spec_type_string = """\
70+ <THE-VALUE/>
71+ """
72+ spec_type_xml = etree .fromstring (spec_type_string )
73+ assert is_self_closed_tag (spec_type_xml ) is True
You can’t perform that action at this time.
0 commit comments