X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=tests%2Fbindings%2Fpython%2Fbt2%2Ftest_error.py;h=ef2a41eae5ac5f79d99913f82a7db4a80010c334;hb=0f77b5c9dfac44ff6eff8fb66fefadea72846c97;hp=2a2703b6f591aa4fc46a2795999d67b4581ef9e6;hpb=082db6480d4f3686922269ec24c2ecc7b2c28bce;p=babeltrace.git diff --git a/tests/bindings/python/bt2/test_error.py b/tests/bindings/python/bt2/test_error.py index 2a2703b6..ef2a41ea 100644 --- a/tests/bindings/python/bt2/test_error.py +++ b/tests/bindings/python/bt2/test_error.py @@ -29,34 +29,34 @@ class FailingIter(bt2._UserMessageIterator): class SourceWithFailingIter( bt2._UserSourceComponent, message_iterator_class=FailingIter ): - def __init__(self, params, obj): + def __init__(self, config, params, obj): self._add_output_port('out') class SourceWithFailingInit( bt2._UserSourceComponent, message_iterator_class=FailingIter ): - def __init__(self, params, obj): + def __init__(self, config, params, obj): raise ValueError('Source is failing') class WorkingSink(bt2._UserSinkComponent): - def __init__(self, params, obj): + def __init__(self, config, params, obj): self._in = self._add_input_port('in') def _user_graph_is_configured(self): - self._iter = self._create_input_port_message_iterator(self._in) + self._iter = self._create_message_iterator(self._in) def _user_consume(self): next(self._iter) class SinkWithExceptionChaining(bt2._UserSinkComponent): - def __init__(self, params, obj): + def __init__(self, config, params, obj): self._in = self._add_input_port('in') def _user_graph_is_configured(self): - self._iter = self._create_input_port_message_iterator(self._in) + self._iter = self._create_message_iterator(self._in) def _user_consume(self): try: @@ -204,3 +204,16 @@ class ErrorTestCase(unittest.TestCase): self.assertEqual(cause.component_class_type, bt2.ComponentClassType.SOURCE) self.assertEqual(cause.component_class_name, 'SourceWithFailingIter') self.assertIsNone(cause.plugin_name) + + def test_str(self): + # Test __str__. We don't need to test the precise format used, but + # just that it doesn't miserably crash and that it contains some + # expected bits. + exc = self._run_failing_graph(SourceWithFailingIter, SinkWithExceptionChaining) + s = str(exc) + self.assertIn("[src (out): 'source.SourceWithFailingIter']", s) + self.assertIn('ValueError: oops', s) + + +if __name__ == '__main__': + unittest.main()