bt2: Make test_query_executor pass
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 3 May 2019 21:25:14 +0000 (17:25 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Sat, 4 May 2019 01:53:49 +0000 (21:53 -0400)
This patch fixes and enables test_query_executor.py.

The only important change is in the query method: it is necessary to
check for `is_canceled` prior to calling the API function, since it
asserts that the executor is not cancelled.

I have removed the __eq__ method and tests, since it's quite unlikely to
be useful for the QueryExecutor class.

Change-Id: If88c2552627358b06f7d6068126034a20ebf88e8
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1252
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
bindings/python/bt2/bt2/query_executor.py
tests/bindings/python/bt2/test_query_executor.py

index f90bb902651cf5fb98c2b43bcab052c35068f250..ce31f694ec73cb83064a0780833ab58bed0d8a38 100644 (file)
@@ -60,6 +60,9 @@ class QueryExecutor(object._SharedObject):
         return is_canceled > 0
 
     def query(self, component_class, object, params=None):
+        if self.is_canceled:
+            raise bt2.QueryExecutorCanceled
+
         if not isinstance(component_class, bt2.component._GenericComponentClass):
             err = False
 
@@ -88,9 +91,3 @@ class QueryExecutor(object._SharedObject):
         self._handle_status(status, 'cannot query component class')
         assert(result_ptr)
         return bt2.value._create_from_ptr(result_ptr)
-
-    def __eq__(self, other):
-        if type(other) is not type(self):
-            return False
-
-        return self.addr == other.addr
index e1b298861f4dc661c3633acf9366e18da8a904e7..e4294be2097c4e3c23d8577aab0dd06b08ae01f6 100644 (file)
@@ -4,7 +4,6 @@ import copy
 import bt2
 
 
-@unittest.skip("this is broken")
 class QueryExecutorTestCase(unittest.TestCase):
     def test_query(self):
         class MySink(bt2._UserSinkComponent):
@@ -122,11 +121,3 @@ class QueryExecutorTestCase(unittest.TestCase):
 
         with self.assertRaises(bt2.QueryExecutorCanceled):
             res = query_exec.query(MySink, 'obj', [17, 23])
-
-    def test_eq(self):
-        query_exec = bt2.QueryExecutor()
-        self.assertEqual(query_exec, query_exec)
-
-    def test_eq_invalid(self):
-        query_exec = bt2.QueryExecutor()
-        self.assertNotEqual(query_exec, 23)
This page took 0.026156 seconds and 4 git commands to generate.