X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=tests%2Fbindings%2Fpython%2Fbt2%2Ftest_trace_class.py;h=f9a21a0ffb276c2ac94a8a64bf88280ce34e54c2;hb=f5567ea88d172767b34373bc6e402da8bfd85ef8;hp=3345b18a913edf0b0174ea99bea860e8d09ee4eb;hpb=64961f8b6306c567fd2683d19a1bdee1331a8d5b;p=babeltrace.git diff --git a/tests/bindings/python/bt2/test_trace_class.py b/tests/bindings/python/bt2/test_trace_class.py index 3345b18a..f9a21a0f 100644 --- a/tests/bindings/python/bt2/test_trace_class.py +++ b/tests/bindings/python/bt2/test_trace_class.py @@ -1,20 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0-only # # Copyright (C) 2019 EfficiOS Inc. # -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; only version 2 -# of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# import unittest from utils import ( @@ -52,10 +39,10 @@ class TraceClassTestCase(unittest.TestCase): def test_create_user_attributes(self): def f(comp_self): - return comp_self._create_trace_class(user_attributes={'salut': 23}) + return comp_self._create_trace_class(user_attributes={"salut": 23}) tc = run_in_component_init(f) - self.assertEqual(tc.user_attributes, {'salut': 23}) + self.assertEqual(tc.user_attributes, {"salut": 23}) def test_create_invalid_user_attributes(self): def f(comp_self): @@ -69,6 +56,14 @@ class TraceClassTestCase(unittest.TestCase): self.assertRaisesInComponentInit(TypeError, f) + def test_create_invalid_automatic_stream_class_id_type(self): + def f(comp_self): + return comp_self._create_trace_class( + assigns_automatic_stream_class_id="perchaude" + ) + + self.assertRaisesInComponentInit(TypeError, f) + def test_automatic_stream_class_id(self): def f(comp_self): return comp_self._create_trace_class(assigns_automatic_stream_class_id=True) @@ -144,7 +139,7 @@ class TraceClassTestCase(unittest.TestCase): def test_getitem_wrong_key_type(self): tc, _, _, _ = self._create_trace_class_with_some_stream_classes() with self.assertRaises(TypeError): - tc['hello'] + tc["hello"] def test_getitem_wrong_key(self): tc, _, _, _ = self._create_trace_class_with_some_stream_classes() @@ -190,9 +185,6 @@ class TraceClassTestCase(unittest.TestCase): trace_class.remove_destruction_listener(handle2) - del handle1 - del handle2 - self.assertEqual(num_destruct_calls, 0) del trace_class @@ -218,7 +210,7 @@ class TraceClassTestCase(unittest.TestCase): with self.assertRaisesRegex( ValueError, - r'This trace class destruction listener does not match the trace object\.', + r"This trace class destruction listener does not match the trace class object\.", ): trace_class_2.remove_destruction_listener(handle1) @@ -232,13 +224,13 @@ class TraceClassTestCase(unittest.TestCase): trace_class.remove_destruction_listener(handle) with self.assertRaisesRegex( - ValueError, r'This trace class destruction listener was already removed\.' + ValueError, r"This trace class destruction listener was already removed\." ): trace_class.remove_destruction_listener(handle) def test_raise_in_destruction_listener(self): def on_trace_class_destruction(trace_class): - raise ValueError('it hurts') + raise ValueError("it hurts") trace_class = get_default_trace_class() trace_class.add_destruction_listener(on_trace_class_destruction) @@ -246,5 +238,5 @@ class TraceClassTestCase(unittest.TestCase): del trace_class -if __name__ == '__main__': +if __name__ == "__main__": unittest.main()