X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=tests%2Fbindings%2Fpython%2Fbt2%2Ftest_error.py;h=6ec5fd89962c47f45b674727057cdcd1f1f8cb9f;hb=59225a3e0e13a9c674234755e55055d9ff68d635;hp=11328db7b1814e427dd56b3123028e4baa866866;hpb=7c14d64103ff43ddeb43aaa04df17beb107f1f78;p=babeltrace.git diff --git a/tests/bindings/python/bt2/test_error.py b/tests/bindings/python/bt2/test_error.py index 11328db7..6ec5fd89 100644 --- a/tests/bindings/python/bt2/test_error.py +++ b/tests/bindings/python/bt2/test_error.py @@ -29,19 +29,19 @@ 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): @@ -52,7 +52,7 @@ class WorkingSink(bt2._UserSinkComponent): 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): @@ -88,7 +88,7 @@ class ErrorTestCase(unittest.TestCase): def test_current_thread_error_none(self): # When a bt2._Error is raised, it steals the current thread's error. # Verify that it is now NULL. - exc = self._run_failing_graph(SourceWithFailingInit, WorkingSink) + self._run_failing_graph(SourceWithFailingInit, WorkingSink) self.assertIsNone(native_bt.current_thread_take_error()) def test_len(self): @@ -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): src.SourceWithFailingIter]', s) + self.assertIn('ValueError: oops', s) + + +if __name__ == '__main__': + unittest.main()