Fix: bt2: pass _TraceClassConst to destruction listeners
[babeltrace.git] / tests / bindings / python / bt2 / test_trace.py
index 8b5537f2c198f163f08476e5b24aafdc35fd4447..3b26826de6acf0fed0188b1665f60331b22f72d8 100644 (file)
@@ -149,11 +149,15 @@ class TraceTestCase(unittest.TestCase):
             num_trace_class_destroyed_calls += 1
 
         def on_trace_destruction(trace):
+            nonlocal type_of_passed_trace
+            type_of_passed_trace = type(trace)
+
             nonlocal num_trace_destroyed_calls
             num_trace_destroyed_calls += 1
 
         num_trace_class_destroyed_calls = 0
         num_trace_destroyed_calls = 0
+        type_of_passed_trace = None
 
         trace_class = get_default_trace_class()
         stream_class = trace_class.create_stream_class()
@@ -168,9 +172,6 @@ class TraceTestCase(unittest.TestCase):
 
         trace.remove_destruction_listener(td_handle2)
 
-        del td_handle1
-        del td_handle2
-
         self.assertEqual(num_trace_class_destroyed_calls, 0)
         self.assertEqual(num_trace_destroyed_calls, 0)
 
@@ -183,6 +184,7 @@ class TraceTestCase(unittest.TestCase):
 
         self.assertEqual(num_trace_class_destroyed_calls, 0)
         self.assertEqual(num_trace_destroyed_calls, 1)
+        self.assertIs(type_of_passed_trace, bt2_trace._TraceConst)
 
         del trace_class
 
@@ -235,6 +237,16 @@ class TraceTestCase(unittest.TestCase):
         ):
             trace.remove_destruction_listener(handle)
 
+    def test_raise_in_destruction_listener(self):
+        def on_trace_destruction(trace):
+            raise ValueError('it hurts')
+
+        trace_class = get_default_trace_class()
+        trace = trace_class()
+        trace.add_destruction_listener(on_trace_destruction)
+
+        del trace
+
 
 if __name__ == '__main__':
     unittest.main()
This page took 0.0239 seconds and 4 git commands to generate.