Move to kernel style SPDX license identifiers
[babeltrace.git] / tests / bindings / python / bt2 / test_graph.py
index f96c8d633c999e0379cb87d4ba8da426599836b8..dfaa69342fd680b40a8b885aec6f533b53eae740 100644 (file)
@@ -1,20 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0-only
 #
 # Copyright (C) 2019 EfficiOS Inc.
 #
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; only version 2
-# of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-#
 
 import unittest
 import bt2
@@ -216,11 +203,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')
 
@@ -243,11 +228,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')
 
@@ -281,9 +264,7 @@ class GraphTestCase(unittest.TestCase):
                 next(self._msg_iter)
 
             def _user_graph_is_configured(self):
-                self._msg_iter = self._create_input_port_message_iterator(
-                    self._input_ports['in']
-                )
+                self._msg_iter = self._create_message_iterator(self._input_ports['in'])
 
         # add two interrupters, set one of them
         interrupter1 = bt2.Interrupter()
@@ -329,9 +310,7 @@ class GraphTestCase(unittest.TestCase):
                 return next(self._msg_iter)
 
             def _user_graph_is_configured(self):
-                self._msg_iter = self._create_input_port_message_iterator(
-                    self._input_ports['in']
-                )
+                self._msg_iter = self._create_message_iterator(self._input_ports['in'])
 
         graph = self._graph
         up = self._graph.add_component(MySource, 'down')
@@ -388,9 +367,7 @@ class GraphTestCase(unittest.TestCase):
                 comp_self._at += 1
 
             def _user_graph_is_configured(self):
-                self._msg_iter = self._create_input_port_message_iterator(
-                    self._input_port
-                )
+                self._msg_iter = self._create_message_iterator(self._input_port)
 
         src = self._graph.add_component(MySource, 'src')
         sink = self._graph.add_component(MySink, 'sink')
@@ -486,9 +463,7 @@ class GraphTestCase(unittest.TestCase):
                 comp_self._at += 1
 
             def _user_graph_is_configured(self):
-                self._msg_iter = self._create_input_port_message_iterator(
-                    self._input_port
-                )
+                self._msg_iter = self._create_message_iterator(self._input_port)
 
         src = self._graph.add_component(MySource, 'src')
         sink = self._graph.add_component(MySink, 'sink')
@@ -543,9 +518,7 @@ class GraphTestCase(unittest.TestCase):
                 comp_self._at += 1
 
             def _user_graph_is_configured(self):
-                self._msg_iter = self._create_input_port_message_iterator(
-                    self._input_port
-                )
+                self._msg_iter = self._create_message_iterator(self._input_port)
 
         src = self._graph.add_component(MySource, 'src')
         sink = self._graph.add_component(MySink, 'sink')
@@ -555,11 +528,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')
@@ -603,11 +574,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.025964 seconds and 4 git commands to generate.