diff --git a/test/test_clib.py b/test/test_clib.py index 20e782e44a231e7ba0a9dfbf82dc4bb7e9804d92..ba34d3497a03b4eaff20df5809d70fa83f7d24c5 100644 --- a/test/test_clib.py +++ b/test/test_clib.py @@ -2,6 +2,7 @@ import os import unittest import ctypes from libevdev._clib import Libevdev, UinputDevice +from pathlib import Path # Note: these tests test for the correct functioning of the python bindings, # not of libevdev underneath. Some ranges are hardcoded for simplicity, e.g. @@ -13,6 +14,10 @@ def is_root(): return os.getuid() == 0 +def has_event_devices(): + return list(Path('/dev/input/').glob('event*')) + + class TestNameConversion(unittest.TestCase): def test_type_max(self): @@ -225,6 +230,7 @@ class TestLibevdevDevice(unittest.TestCase): self.assertEqual(id["version"], 5) +@unittest.skipUnless(has_event_devices(), 'Local event devices required') class TestRealDevice(unittest.TestCase): """ Tests various things against /dev/input/event3 which is usually the @@ -492,6 +498,7 @@ class TestAbsDevice(unittest.TestCase): self.assertTrue(dev.has_property("INPUT_PROP_ACCELEROMETER")) +@unittest.skipUnless(has_event_devices(), 'Local event devices required') class TestMTDevice(unittest.TestCase): """ Tests various things against the first MT device found. @@ -530,6 +537,7 @@ class TestMTDevice(unittest.TestCase): @unittest.skipUnless(is_root(), 'Test requires root') def test_slot_value(self): + dev = Libevdev(self.fd) a = dev.absinfo("ABS_MT_POSITION_X") v = dev.slot_value(dev.current_slot, "ABS_MT_POSITION_X")