mirror of
https://github.com/openwrt/packages.git
synced 2026-04-15 19:02:09 +00:00
The test.sh imports xml.etree.ElementTree from the stdlib, and et_xmlfile itself falls back to stdlib xml when lxml is unavailable. Add python3-xml to DEPENDS to ensure the xml module is present at both install and test time. The test used et_xmlfile.__version__ without importing the et_xmlfile module (only 'from et_xmlfile import xmlfile' was present). Add 'import et_xmlfile' so the version check works correctly. The test.sh lacked a package name guard, causing it to run (and fail) when the -src subpackage was tested without python3 installed. Add the standard guard to skip the test for non-main packages. Signed-off-by: Alexandru Ardelean <alex@shruggie.ro>
33 lines
591 B
Bash
33 lines
591 B
Bash
#!/bin/sh
|
|
|
|
[ "$1" = python3-et_xmlfile ] || exit 0
|
|
|
|
EXPECTED_VER="$2"
|
|
|
|
python3 - << EOF
|
|
|
|
import sys
|
|
from io import BytesIO
|
|
from xml.etree.ElementTree import Element
|
|
|
|
import et_xmlfile
|
|
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
|
|
|