summaryrefslogtreecommitdiffstats
path: root/lang/python/python-lxml/test.sh
blob: e175d9239cd64cbaae8427bf7aac213c0f2d0c8b (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

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