示例#1
0
def test_dump_long_line():
    s = java_manifest.dumps([{
        "test":
        "a" * (java_manifest.LINE_LEN * 2 - len("test: ") - len(" "))
    }])
    assert (
        s ==
        "test: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n"
    )
示例#2
0
def test_encoder():
    s = java_manifest.dumps(
        [{
            "foo": "bar",
            "true": True,
            "false": False,
            "int": 1
        }],
        encoder=example_encoder,
    )
    assert s == "foo: bar\r\ntrue: true\r\nfalse: false\r\nint: 1\r\n"
示例#3
0
def test_repeated():
    original = [{"a": "b"}, {"c": "d"}]
    repeated = java_manifest.loads(java_manifest.dumps(original))
    assert repeated == original
示例#4
0
def test_dump_multiple_sections():
    s = java_manifest.dumps([{"a": "b"}, {"c": "d"}])
    assert s == "a: b\r\n\r\nc: d\r\n"
示例#5
0
def test_dump_int():
    with pytest.raises(ValueError):
        java_manifest.dumps([{"int": 1}])
示例#6
0
def test_dump_bool():
    with pytest.raises(ValueError):
        java_manifest.dumps([{"true": True, "false": False}])
示例#7
0
def test_dump_str():
    s = java_manifest.dumps([{"foo": "bar"}])
    assert s == "foo: bar\r\n"
示例#8
0
def test_dump_bad_keys():
    with pytest.raises(ValueError):
        java_manifest.dumps([{0: 0}])