aboutsummaryrefslogtreecommitdiff
path: root/lang/python/python-lxml/test.sh
blob: 6ea15a0e8e4d327133d7da74d437e09c07e735ac (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
31
#!/bin/sh

[ "$1" = "python3-lxml" ] || exit 0

EXP_VER="$2"

python3 - << EOF
import lxml
import sys

if (lxml.__version__) != "$EXP_VER":
    print("Wrong version: " + lxml.__version__)
    sys.exit(1)

from lxml import etree

root = etree.Element("root")
root.append(etree.Element("child1"))
root.append(etree.Element("child2"))
root.append(etree.Element("child3"))

exp_str = "b'<root><child1/><child2/><child3/></root>'"
got_str = str(etree.tostring(root))
if (got_str != exp_str):
    print("Expected: '" + exp_str + "' . Got: '" + got_str + "'")
else:
    print("OK")

sys.exit(0)
EOF