kumquat-buildroot/support/testing/tests/package/sample_python_avro.py
Romain Naour 5468cf1095 package/python-avro: fix capitalizations of Parse
python-avro 1.11.0 deprecated schema.Parse [1] and actually error
out when used.

Fixes:
https://gitlab.com/buildroot.org/buildroot/-/jobs/2429013770

[1] 3e79dfec84

Signed-off-by: Romain Naour <romain.naour@gmail.com>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2022-05-17 22:50:33 +02:00

24 lines
581 B
Python

from io import BytesIO
from avro.schema import parse
from avro.io import DatumReader, BinaryDecoder
schema = parse("""{
"namespace": "org.buildroot.package.python_avro",
"type": "record",
"name": "Developer",
"fields": [
{"name": "email", "type": "string"},
{"name": "maintainer_of", "type": "string"}
]
}""")
example = b'<titouan.christophe@railnova.eu\x16python_avro'
reader = DatumReader(schema)
deserialized = reader.read(BinaryDecoder(BytesIO(example)))
assert deserialized == {
'email': 'titouan.christophe@railnova.eu',
'maintainer_of': 'python_avro',
}