Example #1
0
 def it_can_set_element_attributes(self, parent_elm, nsptag_str):
     attr_dct = {'foo': 'f', 'bar': 'b'}
     elm = SubElement(parent_elm, nsptag_str, attrib=attr_dct, baz='1')
     assert elm.get('foo') == 'f'
     assert elm.get('bar') == 'b'
     assert elm.get('baz') == '1'
Example #2
0
 def it_returns_an_element_with_the_specified_tag(
         self, parent_elm, nsptag_str):
     elm = SubElement(parent_elm, nsptag_str)
     assert elm.tag == qn(nsptag_str)
Example #3
0
 def it_returns_custom_element_class_if_one_is_defined_for_tag(
         self, parent_elm, nsptag_str):
     # note this behavior depends on the parser of parent_elm being the
     # one on which the custom element class lookups are defined
     elm = SubElement(parent_elm, nsptag_str)
     assert type(elm) is CT_TextBody
Example #4
0
 def it_returns_a_child_of_the_passed_parent_elm(
         self, parent_elm, nsptag_str):
     elm = SubElement(parent_elm, nsptag_str)
     assert elm.getparent() is parent_elm