diff --git a/tests/test_usb.py b/tests/test_usb.py index a0d4f45e9..01ce41a32 100644 --- a/tests/test_usb.py +++ b/tests/test_usb.py @@ -7,6 +7,7 @@ import pytest import os import gi +import subprocess gi.require_version("UMockdev", "1.0") from gi.repository import GLib, UMockdev # noqa E402 @@ -22,6 +23,16 @@ def umockdev(): return UMockdev.Testbed.new() +def umockdev_has_working_remove(): + # umockdev only generates remove events since version 0.18.4 + # https://github.com/martinpitt/umockdev/releases/tag/0.18.4 + required = (0, 18, 4) + + result = subprocess.run(["umockdev-run", "--version"], stdout=subprocess.PIPE) + version = tuple(map(int, result.stdout.decode("UTF-8").strip().split("."))) + return all(v >= r for v, r in zip(version, required)) + + class TestUsb: _num_devices = 0 @@ -188,7 +199,9 @@ def cb_device_events(session_handle, events): ) @pytest.mark.parametrize("usb_queries", ["vnd:04a9", None]) - @pytest.mark.skipif(xdp.is_in_container(), reason="Test fail in containers") + @pytest.mark.skipif( + not umockdev_has_working_remove(), reason="UMockdev version 0.18.4 required" + ) def test_device_remove(self, portals, dbus_con, app_id, usb_queries, umockdev): usb_intf = xdp.get_portal_iface(dbus_con, "Usb")