def begin(self): attrs = HtmlAttributeHolder(**self.element.attributes) attrs.add_attr('class', 'static-form') for attr in ('enctype', 'method', 'action'): try: attrs.del_attr(attr) except KeyError: pass self.output.inc(HTML.div(None, _closed=False, **attrs.attributes))
def test_add_attr(self): ah = HtmlAttributeHolder(src='src', class_='class') ah.add_attr('class_', 'class2') assert ah.attributes['src'] == 'src' assert ah.attributes['class'] == 'class class2'