Path: blob/main/python/pylang/test/elementmaker_.py
1396 views
# vim:fileencoding=utf-81# License: BSD Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>2# globals: assrt34from elementmaker import E56eq = assrt.equal789def dummy_elem_eq(a, b):10eq(jstype(a), jstype(b))11if (jstype(a) == 'string'):12eq(a, b)13return14eq(a.attributes.length, b.attributes.length)15eq(a.children.length, b.children.length)16eq(a.name, b.name)17for attr in a.attributes:18eq(a[attr], b[attr])19for i, child in enumerate(a.children):20dummy_elem_eq(child, b.children[i])212223q = E.div('text', id='1', class_='c', data_x='x')24dummy_elem_eq(25q, {26'name': 'div',27'children': ['text'],28'attributes': {29'id': '1',30'class': 'c',31'data-x': 'x'32}33})3435q = E.div(36E.span('a'),37E.span('b'),38E.a(),39id='1',40boolean_attr=True,41)42dummy_elem_eq(43q, {44'name':45'div',46'children': [47{48'name': 'span',49'children': ['a'],50'attributes': {}51},52{53'name': 'span',54'children': ['b'],55'attributes': {}56},57{58'name': 'a',59'children': [],60'attributes': {}61},62],63'attributes': {64'id': '1',65'boolean-attr': 'boolean-attr'66}67})686970