blob: 9aa06da5af8a4c09067157f466ae592848416ea4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#!/bin/sh
[ "$1" = python3-ruamel-yaml ] || exit 0
python3 - << 'EOF'
from ruamel.yaml import YAML
from io import StringIO
yaml = YAML()
# Test basic load/dump
data = yaml.load("key: value\nlist:\n - a\n - b\n")
assert data["key"] == "value"
assert data["list"] == ["a", "b"]
out = StringIO()
yaml.dump({"x": 1}, out)
assert "x: 1" in out.getvalue()
# Test roundtrip comment preservation (key ruamel.yaml feature)
doc = "# header\nname: test # inline\n"
data2 = yaml.load(doc)
assert data2["name"] == "test"
buf = StringIO()
yaml.dump(data2, buf)
assert "# header" in buf.getvalue()
assert "# inline" in buf.getvalue()
print("python3-ruamel-yaml OK")
EOF
|