b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | #!/bin/sh |
| 2 | |
| 3 | [ "$1" = "python3-lxml" ] || exit 0 |
| 4 | |
| 5 | EXP_VER="$2" |
| 6 | |
| 7 | python3 - << EOF |
| 8 | import lxml |
| 9 | import sys |
| 10 | |
| 11 | if (lxml.__version__) != "$EXP_VER": |
| 12 | print("Wrong version: " + lxml.__version__) |
| 13 | sys.exit(1) |
| 14 | |
| 15 | from lxml import etree |
| 16 | |
| 17 | root = etree.Element("root") |
| 18 | root.append(etree.Element("child1")) |
| 19 | root.append(etree.Element("child2")) |
| 20 | root.append(etree.Element("child3")) |
| 21 | |
| 22 | exp_str = "b'<root><child1/><child2/><child3/></root>'" |
| 23 | got_str = str(etree.tostring(root)) |
| 24 | if (got_str != exp_str): |
| 25 | print("Expected: '" + exp_str + "' . Got: '" + got_str + "'") |
| 26 | else: |
| 27 | print("OK") |
| 28 | |
| 29 | sys.exit(0) |
| 30 | EOF |
| 31 | |