Files
rpi-buildroot/support/testing/tests/package/sample_python_ruamel_yaml.py
Marcus Hoffmann 21da0df09d support/testing: add new python-ruamel-yaml runtime test
Signed-off-by: Marcus Hoffmann <buildroot@bubu1.eu>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2024-07-12 15:04:45 +02:00

28 lines
467 B
Python

from ruamel.yaml import YAML
yaml_text = """
Rootkey:
- ListEntry
AnotherRootKey: some-string
ListRoot:
- float-value: '1.0'
int-value: 10234
NestedList:
- 1
- 2
- another-float: '1.1'
another-int: 1111
OneMoreRootKey: 9.99
"""
# Tests the pure python based implementation
yaml = YAML(typ='safe', pure=True)
parsed = yaml.load(yaml_text)
assert parsed['OneMoreRootKey'] == 9.99
assert parsed['ListRoot'][1]['another-int'] == 1111