tests: remove unnecessary message iterator classes
[babeltrace.git] / tests / bindings / python / bt2 / test_graph.py
index 3a52dd45a3850d09637324476598d51f3423a76c..7c18e8a79256a98afde305af9300614a906db708 100644 (file)
@@ -65,6 +65,10 @@ class GraphTestCase(unittest.TestCase):
         with self.assertRaisesRegex(ValueError, 'unknown MIP version'):
             bt2.Graph(1)
 
+    def test_default_interrupter(self):
+        interrupter = self._graph.default_interrupter
+        self.assertIs(type(interrupter), bt2.Interrupter)
+
     def test_add_component_user_cls(self):
         class MySink(bt2._UserSinkComponent):
             def _user_consume(self):
@@ -212,11 +216,9 @@ class GraphTestCase(unittest.TestCase):
         self.assertEqual(comp.logging_level, bt2.LoggingLevel.DEBUG)
 
     def test_connect_ports(self):
-        class MyIter(bt2._UserMessageIterator):
-            def __next__(self):
-                raise bt2.Stop
-
-        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
+        class MySource(
+            bt2._UserSourceComponent, message_iterator_class=bt2._UserMessageIterator
+        ):
             def __init__(self, config, params, obj):
                 self._add_output_port('out')
 
@@ -239,11 +241,9 @@ class GraphTestCase(unittest.TestCase):
         self.assertEqual(sink.input_ports['in'].connection.addr, conn.addr)
 
     def test_connect_ports_invalid_direction(self):
-        class MyIter(bt2._UserMessageIterator):
-            def __next__(self):
-                raise bt2.Stop
-
-        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
+        class MySource(
+            bt2._UserSourceComponent, message_iterator_class=bt2._UserMessageIterator
+        ):
             def __init__(self, config, params, obj):
                 self._add_output_port('out')
 
@@ -321,7 +321,7 @@ class GraphTestCase(unittest.TestCase):
             def _user_consume(self):
                 # Pretend that somebody asynchronously interrupted the graph.
                 nonlocal graph
-                graph.interrupt()
+                graph.default_interrupter.set()
                 return next(self._msg_iter)
 
             def _user_graph_is_configured(self):
@@ -551,11 +551,9 @@ class GraphTestCase(unittest.TestCase):
             self._graph.run()
 
     def test_listeners(self):
-        class MyIter(bt2._UserMessageIterator):
-            def __next__(self):
-                raise bt2.Stop
-
-        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
+        class MySource(
+            bt2._UserSourceComponent, message_iterator_class=bt2._UserMessageIterator
+        ):
             def __init__(self, config, params, obj):
                 self._add_output_port('out')
                 self._add_output_port('zero')
@@ -599,11 +597,9 @@ class GraphTestCase(unittest.TestCase):
         self.assertEqual(calls[3][2].name, 'taste')
 
     def test_invalid_listeners(self):
-        class MyIter(bt2._UserMessageIterator):
-            def __next__(self):
-                raise bt2.Stop
-
-        class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
+        class MySource(
+            bt2._UserSourceComponent, message_iterator_class=bt2._UserMessageIterator
+        ):
             def __init__(self, config, params, obj):
                 self._add_output_port('out')
                 self._add_output_port('zero')
This page took 0.026366 seconds and 4 git commands to generate.