Exemplo n.º 1
0
def test_overriding_attributes():
    xml_struct = Struct(
        "testa",
        Struct("testb", Int("testint", {"attr": "attra"}),
               String("string", {"attr": "attrv"})))
    obj = Container(
        testb={
            "testint": ValueContainer(3, xml_attrib={"attr": "attrb"}),
            "string": "night"
        })
    assert xml_struct.build(
        obj
    ) == '<testa><testb><testint attr="attrb">3</testint><string attr="attrv">night</string></testb></testa>'
Exemplo n.º 2
0
def test_int_parse():
    obj = ValueContainer(6, xml_attrib={"attr": "check"})
    assert Int("test").parse('<test attr="check">6</test>') == obj
Exemplo n.º 3
0
def test_hex_parse():
    obj = ValueContainer(255)
    assert Hex("test").parse('<test>FF</test>') == obj
Exemplo n.º 4
0
def test_int_build():
    obj = ValueContainer(6, xml_attrib={"attr": "check"})
    assert Int("test").build(obj) == '<test attr="check">6</test>'
Exemplo n.º 5
0
def test_empty_string_parse():
    obj = ValueContainer("")
    assert String("brooo").parse('<brooo></brooo>') == obj
    assert String("brooo").parse('<brooo />') == obj
Exemplo n.º 6
0
def test_string_parse():
    obj = ValueContainer("or")
    assert String("ts").parse('<ts>or</ts>') == obj
Exemplo n.º 7
0
def test_float_parse():
    obj = ValueContainer(4.2)
    assert Float("test").parse('<test>4.2</test>') == obj