X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=tests%2Fbindings%2Fpython%2Fbt2%2Ftest_graph.py;h=7c18e8a79256a98afde305af9300614a906db708;hb=5c61fb9d5be835a0efc87f7764117c4d05e0ae5a;hp=3a52dd45a3850d09637324476598d51f3423a76c;hpb=2945edfe752782d2528af21bdbd3bbfef4cd51ca;p=babeltrace.git diff --git a/tests/bindings/python/bt2/test_graph.py b/tests/bindings/python/bt2/test_graph.py index 3a52dd45..7c18e8a7 100644 --- a/tests/bindings/python/bt2/test_graph.py +++ b/tests/bindings/python/bt2/test_graph.py @@ -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')