[PATCH evemu 11/11] py: Change has_prop() and has_event() to return bool

Daniel Martin consume.noise at gmail.com
Thu Jan 2 13:48:01 PST 2014


Change has_prop() and has_event() to return a bool instead of an int
coming from the library call.

Signed-off-by: Daniel Martin <consume.noise at gmail.com>
---
 python/evemu/__init__.py          | 14 +++++++-------
 python/evemu/tests/test_device.py |  6 +++---
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/python/evemu/__init__.py b/python/evemu/__init__.py
index 20d82b5..72d3841 100644
--- a/python/evemu/__init__.py
+++ b/python/evemu/__init__.py
@@ -259,9 +259,9 @@ class Device(object):
                                  event_code)
 
     def has_prop(self, event_code):
-        return self._evemu._call(self._evemu.get_lib().evemu_has_prop,
-                                 self._evemu_device,
-                                 event_code)
+        return bool(self._evemu._call(self._evemu.get_lib().evemu_has_prop,
+                                      self._evemu_device,
+                                      event_code))
 
     def has_event(self, event_type, event_code):
         """
@@ -275,8 +275,8 @@ class Device(object):
         used to simulate gestures for a higher number of touches than are
         possible with just 2-touch hardware.
         """
-        return self._evemu._call(self._evemu.get_lib().evemu_has_event,
-                                 self._evemu_device,
-                                 event_type,
-                                 event_code)
+        return bool(self._evemu._call(self._evemu.get_lib().evemu_has_event,
+                                      self._evemu_device,
+                                      event_type,
+                                      event_code))
 
diff --git a/python/evemu/tests/test_device.py b/python/evemu/tests/test_device.py
index ceac1b3..3fefa78 100644
--- a/python/evemu/tests/test_device.py
+++ b/python/evemu/tests/test_device.py
@@ -190,21 +190,21 @@ class DevicePropertiesTestCase(testcase.BaseTestCase):
 
     def test_has_prop(self):
         keys = evemu.const.absolute_axes.values()
-        results = {x: bool(self._device.has_prop(x)) for x in keys}
+        results = {x: self._device.has_prop(x) for x in keys}
 
         self.assertEqual(results, self.get_expected_prop())
 
     def test_has_event_ev_abs(self):
         ev_abs = evemu.const.event_types["EV_ABS"]
         keys = evemu.const.absolute_axes.values()
-        results = {x: bool(self._device.has_event(ev_abs, x)) for x in keys}
+        results = {x: self._device.has_event(ev_abs, x) for x in keys}
 
         self.assertEqual(results, self.get_expected_ev_abs())
 
     def test_has_event_ev_key(self):
         ev_key = evemu.const.event_types["EV_KEY"]
         keys = evemu.const.buttons.values()
-        results = {x: bool(self._device.has_event(ev_key, x)) for x in keys}
+        results = {x: self._device.has_event(ev_key, x) for x in keys}
 
         self.assertEqual(results, self.get_expected_ev_key())
 
-- 
1.8.5.2



More information about the Input-tools mailing list