lib: pass config objects to component init methods
[babeltrace.git] / tests / bindings / python / bt2 / test_graph.py
index 1d3f9da27be726606de2f635ebc2056faa0ba8a2..347f8803dba0768e946e9b2de59e81f7fe78958f 100644 (file)
@@ -87,7 +87,7 @@ class GraphTestCase(unittest.TestCase):
         comp_params = None
 
         class MySink(bt2._UserSinkComponent):
-            def __init__(self, params, obj):
+            def __init__(self, config, params, obj):
                 nonlocal comp_params
                 comp_params = params
 
@@ -103,7 +103,7 @@ class GraphTestCase(unittest.TestCase):
         comp_obj = None
 
         class MySink(bt2._UserSinkComponent):
-            def __init__(self, params, obj):
+            def __init__(self, config, params, obj):
                 nonlocal comp_obj
                 comp_obj = obj
 
@@ -119,7 +119,7 @@ class GraphTestCase(unittest.TestCase):
         comp_obj = None
 
         class MySink(bt2._UserSinkComponent):
-            def __init__(self, params, obj):
+            def __init__(self, config, params, obj):
                 nonlocal comp_obj
                 comp_obj = obj
 
@@ -175,11 +175,11 @@ class GraphTestCase(unittest.TestCase):
                 raise bt2.Stop
 
         class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
-            def __init__(self, params, obj):
+            def __init__(self, config, params, obj):
                 self._add_output_port('out')
 
         class MySink(bt2._UserSinkComponent):
-            def __init__(self, params, obj):
+            def __init__(self, config, params, obj):
                 self._add_input_port('in')
 
             def _user_consume(self):
@@ -202,11 +202,11 @@ class GraphTestCase(unittest.TestCase):
                 raise bt2.Stop
 
         class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
-            def __init__(self, params, obj):
+            def __init__(self, config, params, obj):
                 self._add_output_port('out')
 
         class MySink(bt2._UserSinkComponent):
-            def __init__(self, params, obj):
+            def __init__(self, config, params, obj):
                 self._add_input_port('in')
 
             def _user_consume(self):
@@ -224,11 +224,11 @@ class GraphTestCase(unittest.TestCase):
                 raise TypeError
 
         class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
-            def __init__(self, params, obj):
+            def __init__(self, config, params, obj):
                 self._add_output_port('out')
 
         class MySink(bt2._UserSinkComponent):
-            def __init__(self, params, obj):
+            def __init__(self, config, params, obj):
                 self._add_input_port('in')
 
             def _user_consume(self):
@@ -269,11 +269,11 @@ class GraphTestCase(unittest.TestCase):
                 return self._create_stream_beginning_message(self._stream)
 
         class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
-            def __init__(self, params, obj):
+            def __init__(self, config, params, obj):
                 self._add_output_port('out')
 
         class MySink(bt2._UserSinkComponent):
-            def __init__(self, params, obj):
+            def __init__(self, config, params, obj):
                 self._add_input_port('in')
 
             def _user_consume(self):
@@ -316,11 +316,11 @@ class GraphTestCase(unittest.TestCase):
                 return msg
 
         class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
-            def __init__(self, params, obj):
+            def __init__(self, config, params, obj):
                 self._add_output_port('out')
 
         class MySink(bt2._UserSinkComponent):
-            def __init__(self, params, obj):
+            def __init__(self, config, params, obj):
                 self._input_port = self._add_input_port('in')
                 self._at = 0
 
@@ -328,16 +328,16 @@ class GraphTestCase(unittest.TestCase):
                 msg = next(comp_self._msg_iter)
 
                 if comp_self._at == 0:
-                    self.assertIsInstance(msg, bt2._StreamBeginningMessage)
+                    self.assertIs(type(msg), bt2._StreamBeginningMessageConst)
                 elif comp_self._at == 1:
-                    self.assertIsInstance(msg, bt2._PacketBeginningMessage)
+                    self.assertIs(type(msg), bt2._PacketBeginningMessageConst)
                 elif comp_self._at >= 2 and comp_self._at <= 6:
-                    self.assertIsInstance(msg, bt2._EventMessage)
+                    self.assertIs(type(msg), bt2._EventMessageConst)
                     self.assertEqual(msg.event.cls.name, 'salut')
                 elif comp_self._at == 7:
-                    self.assertIsInstance(msg, bt2._PacketEndMessage)
+                    self.assertIs(type(msg), bt2._PacketEndMessageConst)
                 elif comp_self._at == 8:
-                    self.assertIsInstance(msg, bt2._StreamEndMessage)
+                    self.assertIs(type(msg), bt2._StreamEndMessageConst)
 
                 comp_self._at += 1
 
@@ -356,11 +356,11 @@ class GraphTestCase(unittest.TestCase):
             pass
 
         class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
-            def __init__(self, params, obj):
+            def __init__(self, config, params, obj):
                 self._add_output_port('out')
 
         class MySink(bt2._UserSinkComponent):
-            def __init__(self, params, obj):
+            def __init__(self, config, params, obj):
                 self._input_port = self._add_input_port('in')
 
             def _user_consume(comp_self):
@@ -383,11 +383,11 @@ class GraphTestCase(unittest.TestCase):
             pass
 
         class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
-            def __init__(self, params, obj):
+            def __init__(self, config, params, obj):
                 self._add_output_port('out')
 
         class MySink(bt2._UserSinkComponent):
-            def __init__(self, params, obj):
+            def __init__(self, config, params, obj):
                 self._input_port = self._add_input_port('in')
 
             def _user_consume(comp_self):
@@ -417,22 +417,22 @@ class GraphTestCase(unittest.TestCase):
                 return msg
 
         class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
-            def __init__(self, params, obj):
+            def __init__(self, config, params, obj):
                 self._add_output_port('out')
 
         class MySink(bt2._UserSinkComponent):
-            def __init__(self, params, obj):
+            def __init__(self, config, params, obj):
                 self._input_port = self._add_input_port('in')
                 self._at = 0
 
             def _user_consume(comp_self):
                 msg = next(comp_self._msg_iter)
                 if comp_self._at == 0:
-                    self.assertIsInstance(msg, bt2._StreamBeginningMessage)
+                    self.assertIs(type(msg), bt2._StreamBeginningMessageConst)
                 elif comp_self._at == 1:
-                    self.assertIsInstance(msg, bt2._PacketBeginningMessage)
+                    self.assertIs(type(msg), bt2._PacketBeginningMessageConst)
                 elif comp_self._at == 2:
-                    self.assertIsInstance(msg, bt2._EventMessage)
+                    self.assertIs(type(msg), bt2._EventMessageConst)
                     raise bt2.TryAgain
                 else:
                     pass
@@ -473,22 +473,22 @@ class GraphTestCase(unittest.TestCase):
                 return msg
 
         class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
-            def __init__(self, params, obj):
+            def __init__(self, config, params, obj):
                 self._add_output_port('out')
 
         class MySink(bt2._UserSinkComponent):
-            def __init__(self, params, obj):
+            def __init__(self, config, params, obj):
                 self._input_port = self._add_input_port('in')
                 self._at = 0
 
             def _user_consume(comp_self):
                 msg = next(comp_self._msg_iter)
                 if comp_self._at == 0:
-                    self.assertIsInstance(msg, bt2._StreamBeginningMessage)
+                    self.assertIs(type(msg), bt2._StreamBeginningMessageConst)
                 elif comp_self._at == 1:
-                    self.assertIsInstance(msg, bt2._PacketBeginningMessage)
+                    self.assertIs(type(msg), bt2._PacketBeginningMessageConst)
                 elif comp_self._at == 2:
-                    self.assertIsInstance(msg, bt2._EventMessage)
+                    self.assertIs(type(msg), bt2._EventMessageConst)
                 elif comp_self._at == 3:
                     nonlocal raised_in_sink
                     raised_in_sink = True
@@ -514,12 +514,12 @@ class GraphTestCase(unittest.TestCase):
                 raise bt2.Stop
 
         class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
-            def __init__(self, params, obj):
+            def __init__(self, config, params, obj):
                 self._add_output_port('out')
                 self._add_output_port('zero')
 
         class MySink(bt2._UserSinkComponent):
-            def __init__(self, params, obj):
+            def __init__(self, config, params, obj):
                 self._add_input_port('in')
 
             def _user_consume(self):
@@ -583,12 +583,12 @@ class GraphTestCase(unittest.TestCase):
                 raise bt2.Stop
 
         class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
-            def __init__(self, params, obj):
+            def __init__(self, config, params, obj):
                 self._add_output_port('out')
                 self._add_output_port('zero')
 
         class MySink(bt2._UserSinkComponent):
-            def __init__(self, params, obj):
+            def __init__(self, config, params, obj):
                 self._add_input_port('in')
 
             def _user_consume(self):
@@ -604,7 +604,7 @@ class GraphTestCase(unittest.TestCase):
 
     def test_raise_in_component_init(self):
         class MySink(bt2._UserSinkComponent):
-            def __init__(self, params, obj):
+            def __init__(self, config, params, obj):
                 raise ValueError('oops!')
 
             def _user_consume(self):
@@ -617,7 +617,7 @@ class GraphTestCase(unittest.TestCase):
 
     def test_raise_in_port_added_listener(self):
         class MySink(bt2._UserSinkComponent):
-            def __init__(self, params, obj):
+            def __init__(self, config, params, obj):
                 self._add_input_port('in')
 
             def _user_consume(self):
@@ -638,11 +638,11 @@ class GraphTestCase(unittest.TestCase):
                 raise bt2.Stop
 
         class MySource(bt2._UserSourceComponent, message_iterator_class=MyIter):
-            def __init__(self, params, obj):
+            def __init__(self, config, params, obj):
                 self._add_output_port('out')
 
         class MySink(bt2._UserSinkComponent):
-            def __init__(self, params, obj):
+            def __init__(self, config, params, obj):
                 self._add_input_port('in')
 
             def _user_consume(self):
@@ -660,3 +660,7 @@ class GraphTestCase(unittest.TestCase):
 
         with self.assertRaises(bt2._Error):
             graph.connect_ports(up.output_ports['out'], down.input_ports['in'])
+
+
+if __name__ == '__main__':
+    unittest.main()
This page took 0.02942 seconds and 4 git commands to generate.