summaryrefslogtreecommitdiffstats
path: root/lang/python/python-et_xmlfile/test.sh
blob: cb4e5af26697ef77800bdab137cf7f31088d298f (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
#!/bin/sh

EXPECTED_VER="$2"

python3 - << EOF

import sys
from io import BytesIO
from xml.etree.ElementTree import Element

from et_xmlfile import xmlfile

if (et_xmlfile.__version__ != "$EXPECTED_VER"):
    print("Invalid version obtained '" + et_xmlfile.__version__ + "'")
    sys.exit(1)

out = BytesIO()
with xmlfile(out) as xf:
    el = Element("root")
    xf.write(el) # write the XML straight to the file-like object

if (out.getvalue() != b"<root />"):
    print("Does not seem to work")
    sys.exit(1)

sys.exit(0)

EOF