From d3c84656f7b7c1cf183c9e006ad45db3dba9cfa3 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Tue, 10 Mar 2026 12:32:38 +0000 Subject: [PATCH] python-pyudev: add some basic tests These are a massive help for keeping things stable on the mid-to-longterm when updating packages. We might even feel comfortable partially automating the process. Signed-off-by: Alexandru Ardelean --- lang/python/python-pyudev/test.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 lang/python/python-pyudev/test.sh diff --git a/lang/python/python-pyudev/test.sh b/lang/python/python-pyudev/test.sh new file mode 100755 index 0000000000..a892c6117f --- /dev/null +++ b/lang/python/python-pyudev/test.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +[ "$1" = "python3-pyudev" ] || exit 0 + +python3 - << EOF +import sys +import pyudev + +if pyudev.__version__ != "$2": + print("Wrong version: " + pyudev.__version__) + sys.exit(1) + +# Verify key classes are importable +from pyudev import Context, Device, Devices, Enumerator, Monitor +from pyudev import DeviceNotFoundAtPathError, DeviceNotFoundByNameError + +# Create a Context (requires libudev to be available) +ctx = Context() + +# Enumerate devices - libudev-zero may return an empty list, just verify no crash +enumerator = ctx.list_devices() +assert isinstance(enumerator, Enumerator) +list(enumerator) # consume iterator + +sys.exit(0) +EOF