diff --git a/examples/evtest.py b/examples/evtest.py index 4acddf78c3aa728d1dfcc48ac3830a7be1400efa..2ded6a29b307d4333cd7270ac8378ca9a3075d7d 100755 --- a/examples/evtest.py +++ b/examples/evtest.py @@ -42,16 +42,16 @@ def print_capabilities(l): def print_event(e): - print("Event: time {}.{:06d}, ".format(e.sec, e.usec), end='') - if e.matches(libevdev.EV_SYN): - if e.matches(libevdev.EV_SYN.SYN_MT_REPORT): - print("++++++++++++++ {} ++++++++++++".format(e.code.name)) - elif e.matches(libevdev.EV_SYN.SYN_DROPPED): - print(">>>>>>>>>>>>>> {} >>>>>>>>>>>>".format(e.code.name)) - else: - print("-------------- {} ------------".format(e.code.name)) + print("Event: time {}.{:06d}, ".format(e.sec, e.usec), end='') + if e.matches(libevdev.EV_SYN): + if e.matches(libevdev.EV_SYN.SYN_MT_REPORT): + print("++++++++++++++ {} ++++++++++++".format(e.code.name)) + elif e.matches(libevdev.EV_SYN.SYN_DROPPED): + print(">>>>>>>>>>>>>> {} >>>>>>>>>>>>".format(e.code.name)) else: - print("type {:02x} {} code {:03x} {:20s} value {:4d}".format(e.type.value, e.type.name, e.code.value, e.code.name, e.value)) + print("-------------- {} ------------".format(e.code.name)) + else: + print("type {:02x} {} code {:03x} {:20s} value {:4d}".format(e.type.value, e.type.name, e.code.value, e.code.name, e.value)) def main(args): diff --git a/examples/kernel-device-update.py b/examples/kernel-device-update.py index 3f10c4e60d51b52870f92faba917270636effcc4..f0c17f6b1a75c836992628f90ed94e082086dd69 100755 --- a/examples/kernel-device-update.py +++ b/examples/kernel-device-update.py @@ -8,6 +8,7 @@ import sys import libevdev + def main(args): path = args[1] axis = args[2] @@ -38,4 +39,3 @@ if __name__ == "__main__": print(" <value> .. the numeric value to set the axis field to") sys.exit(1) main(sys.argv) - diff --git a/setup.py b/setup.py index 3729316d052636c0b9c67bab20111be0f72029e7..5329711a1436cb5f1f118c481f55c9bd8ecf2ade 100755 --- a/setup.py +++ b/setup.py @@ -26,7 +26,6 @@ setup(name='libevdev', 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', 'Programming Language :: Python :: 3', - ], + ], python_requires='>=3', - keywords='evdev input uinput libevdev', -) + keywords='evdev input uinput libevdev') diff --git a/test/test_clib.py b/test/test_clib.py index 0ba00cb13def9141c95192eabeafc44c8adc622f..f63013d19dbf3e5769948b242c69b2a271577a34 100644 --- a/test/test_clib.py +++ b/test/test_clib.py @@ -8,9 +8,11 @@ from libevdev._clib import Libevdev, UinputDevice # if properties 1-4 work the others will work too if libevdev works # correctly + def is_root(): return os.getuid() == 0 + class TestNameConversion(unittest.TestCase): def test_type_max(self): @@ -445,6 +447,7 @@ class TestAbsDevice(unittest.TestCase): l.enable_property("INPUT_PROP_ACCELEROMETER") self.assertTrue(l.has_property("INPUT_PROP_ACCELEROMETER")) + class TestMTDevice(unittest.TestCase): """ Tests various things against the first MT device found. diff --git a/test/test_const.py b/test/test_const.py index 3c9ce2830f4712def301237afb6f51afc9eb8237..90e991ebff83612630e38a32d11eb0048687fbdc 100644 --- a/test/test_const.py +++ b/test/test_const.py @@ -25,6 +25,7 @@ import unittest import libevdev from libevdev import evbit, propbit + class TestEventBits(unittest.TestCase): def test_ev_types(self): self.assertIn(libevdev.EV_SYN, libevdev.types) diff --git a/test/test_device.py b/test/test_device.py index 2de150443611d43d536e93dc2a0d1d6d05bae65b..f4d9b2c08e62993c300ca06351a935a04f8a4aba 100644 --- a/test/test_device.py +++ b/test/test_device.py @@ -24,16 +24,18 @@ import os import unittest import libevdev -from libevdev import evbit, propbit, InputEvent, Device, InvalidFileError, InvalidArgumentException +from libevdev import InvalidFileError, InvalidArgumentException + def is_root(): return os.getuid() == 0 + class TestDevice(unittest.TestCase): def test_device_empty(self): d = libevdev.Device() id = {'bustype': 0, 'vendor': 0, 'product': 0, 'version': 0} - syns = { libevdev.EV_SYN : libevdev.EV_SYN.codes } + syns = {libevdev.EV_SYN: libevdev.EV_SYN.codes} self.assertEqual(d.name, '') self.assertEqual(d.id, id) @@ -55,10 +57,8 @@ class TestDevice(unittest.TestCase): for c in t.codes: self.assertFalse(d.has(c)) self.assertIsNone(d.value[c]) - - d.disable(c) # noop - - d.disable(t) # noop + d.disable(c) # noop + d.disable(t) # noop for p in libevdev.props: self.assertFalse(d.has_property(p)) @@ -232,7 +232,7 @@ class TestDevice(unittest.TestCase): self.assertEqual(d.properties, props) for p in libevdev.props: - if not p in props: + if p not in props: self.assertFalse(d.has_property(p)) else: self.assertTrue(d.has_property(p)) diff --git a/test/test_events.py b/test/test_events.py index 361b9abca47806c88f28eacdefcc1f5987155407..dead784df85baa9b9d5a66369e0e0ccab9a3008a 100644 --- a/test/test_events.py +++ b/test/test_events.py @@ -23,7 +23,8 @@ import unittest import libevdev -from libevdev import evbit, propbit, InputEvent +from libevdev import InputEvent + class TestEvents(unittest.TestCase): def test_event_matches_type(self):