summaryrefslogtreecommitdiffstats
path: root/lang/python/python-pyudev/test.sh
blob: a892c6117f3b32dd262e1275660fc43d485f8720 (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
#!/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