bt2: use format_bt_error and format_bt_error_cause to generate _Error and _ErrorCause...
[babeltrace.git] / tests / bindings / python / bt2 / test_error.py
index 821d30f5a25b485edfbc1b58c43d6b44f1cde620..f11cb2c2e92cf912d7ca5cd06a76136a06521514 100644 (file)
@@ -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):
@@ -205,6 +205,15 @@ class ErrorTestCase(unittest.TestCase):
         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()
This page took 0.023573 seconds and 4 git commands to generate.