X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=tests%2Fbindings%2Fpython%2Fbt2%2Ftest_message_iterator.py;h=01d4eca3c5b9d0d4d768dd6304554b6b2b01512d;hp=2d4ab43850774131ffa9982355639079aa3f518b;hb=f2fb1b3297ca0bc13b53189a063b63944be7fae9;hpb=0a6d7302f774fbd35d7439889734acd418e8ef14 diff --git a/tests/bindings/python/bt2/test_message_iterator.py b/tests/bindings/python/bt2/test_message_iterator.py index 2d4ab438..01d4eca3 100644 --- a/tests/bindings/python/bt2/test_message_iterator.py +++ b/tests/bindings/python/bt2/test_message_iterator.py @@ -457,6 +457,60 @@ class UserMessageIteratorSeekBeginningTestCase(unittest.TestCase): graph.run_once() self.assertFalse(can_seek_beginning) + def test_can_seek_beginning_user_error(self): + class MySink(bt2._UserSinkComponent): + def __init__(self, params, obj): + self._add_input_port('in') + + def _user_graph_is_configured(self): + self._msg_iter = self._create_input_port_message_iterator( + self._input_ports['in'] + ) + + def _user_consume(self): + # This is expected to raise. + self._msg_iter.can_seek_beginning + + def _user_can_seek_beginning(self): + raise ValueError('moustiquaire') + + graph = _setup_seek_test( + MySink, user_can_seek_beginning=_user_can_seek_beginning + ) + + with self.assertRaises(bt2._Error) as ctx: + graph.run_once() + + cause = ctx.exception[0] + self.assertIn('ValueError: moustiquaire', cause.message) + + def test_can_seek_beginning_wrong_return_value(self): + class MySink(bt2._UserSinkComponent): + def __init__(self, params, obj): + self._add_input_port('in') + + def _user_graph_is_configured(self): + self._msg_iter = self._create_input_port_message_iterator( + self._input_ports['in'] + ) + + def _user_consume(self): + # This is expected to raise. + self._msg_iter.can_seek_beginning + + def _user_can_seek_beginning(self): + return 'Amqui' + + graph = _setup_seek_test( + MySink, user_can_seek_beginning=_user_can_seek_beginning + ) + + with self.assertRaises(bt2._Error) as ctx: + graph.run_once() + + cause = ctx.exception[0] + self.assertIn("TypeError: 'str' is not a 'bool' object", cause.message) + def test_seek_beginning(self): class MySink(bt2._UserSinkComponent): def __init__(self, params, obj):