예제 #1
0
def test_1():
    """Test for empty parameters."""

    params = yami.Parameters()

    assert len(params) == 0

    assert str(params) == ""

    try:
        del params["no such entry"]
        assert False
    except KeyError as e:
        assert str(e) == \
            "\"Entry or object named 'no such entry' does not exist.\""

    # check for empty iteration
    for e in params:
        assert False

    try:
        e = params["no such name"]
        assert False
    except KeyError:
        pass

    assert "no such name" not in params

    serialized = b"\x00\x00\x00\x00"

    buf = params.serialize()
    assert buf == serialized

    params2 = yami.Parameters()
    params2.deserialize(buf)
    assert len(params2) == 0

    # additional test for plain dictionary
    assert yami.serialize({}) == serialized
예제 #2
0
    except KeyError:
        pass

    assert "no such name" not in params

    serialized = "\x00\x00\x00\x00"

    buf = params.serialize()
    assert buf == serialized

    params2 = yami.Parameters()
    params2.deserialize(buf)
    assert len(params2) == 0

    # additional test for plain dictionary
    assert yami.serialize({}) == serialized

def test_2():
    """Test for bool."""

    params = yami.Parameters()

    params["name"] = True

    assert len(params) == 1

    assert type(params["name"]) == bool

    assert params["name"] == True

    assert str(params) == (