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" )
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"
def test_repeated(): original = [{"a": "b"}, {"c": "d"}] repeated = java_manifest.loads(java_manifest.dumps(original)) assert repeated == original
def test_dump_multiple_sections(): s = java_manifest.dumps([{"a": "b"}, {"c": "d"}]) assert s == "a: b\r\n\r\nc: d\r\n"
def test_dump_int(): with pytest.raises(ValueError): java_manifest.dumps([{"int": 1}])
def test_dump_bool(): with pytest.raises(ValueError): java_manifest.dumps([{"true": True, "false": False}])
def test_dump_str(): s = java_manifest.dumps([{"foo": "bar"}]) assert s == "foo: bar\r\n"
def test_dump_bad_keys(): with pytest.raises(ValueError): java_manifest.dumps([{0: 0}])