X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=tests%2Fbindings%2Fpython%2Fbt2%2Ftest_stream_class.py;h=3668fe865bb8df2c33ec8ee76d08e7b0afc49ebc;hb=HEAD;hp=09537ee85332e245d9414b79899691c4522ea859;hpb=d3bf1370a437239053f532d73c4e04df53827bb9;p=babeltrace.git diff --git a/tests/bindings/python/bt2/test_stream_class.py b/tests/bindings/python/bt2/test_stream_class.py index 09537ee8..3668fe86 100644 --- a/tests/bindings/python/bt2/test_stream_class.py +++ b/tests/bindings/python/bt2/test_stream_class.py @@ -1,28 +1,16 @@ +# 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 run_in_component_init -from bt2 import stream_class as bt2_stream_class -from bt2 import trace_class as bt2_trace_class + from bt2 import clock_class as bt2_clock_class from bt2 import event_class as bt2_event_class from bt2 import field_class as bt2_field_class +from bt2 import trace_class as bt2_trace_class +from bt2 import stream_class as bt2_stream_class +from utils import run_in_component_init class StreamClassTestCase(unittest.TestCase): @@ -55,8 +43,8 @@ class StreamClassTestCase(unittest.TestCase): self.assertEqual(len(sc.user_attributes), 0) def test_create_name(self): - sc = self._tc.create_stream_class(name='bozo') - self.assertEqual(sc.name, 'bozo') + sc = self._tc.create_stream_class(name="bozo") + self.assertEqual(sc.name, "bozo") def test_create_invalid_name(self): with self.assertRaisesRegex(TypeError, "'int' is not a 'str' object"): @@ -128,8 +116,8 @@ class StreamClassTestCase(unittest.TestCase): self.assertEqual(len(self._tc), 0) def test_create_user_attributes(self): - sc = self._tc.create_stream_class(user_attributes={'salut': 23}) - self.assertEqual(sc.user_attributes, {'salut': 23}) + sc = self._tc.create_stream_class(user_attributes={"salut": 23}) + self.assertEqual(sc.user_attributes, {"salut": 23}) def test_create_invalid_user_attributes(self): with self.assertRaisesRegex( @@ -168,7 +156,7 @@ class StreamClassTestCase(unittest.TestCase): def test_automatic_stream_ids_wrong_type(self): with self.assertRaisesRegex(TypeError, "str' is not a 'bool' object"): - self._tc.create_stream_class(assigns_automatic_stream_id='True') + self._tc.create_stream_class(assigns_automatic_stream_id="True") self.assertEqual(len(self._tc), 0) @@ -212,7 +200,7 @@ class StreamClassTestCase(unittest.TestCase): def test_automatic_event_class_ids_wrong_type(self): with self.assertRaisesRegex(TypeError, "'str' is not a 'bool' object"): - self._tc.create_stream_class(assigns_automatic_event_class_id='True') + self._tc.create_stream_class(assigns_automatic_event_class_id="True") self.assertEqual(len(self._tc), 0) @@ -357,6 +345,20 @@ class StreamClassTestCase(unittest.TestCase): self.assertEqual(len(self._tc), 0) + def test_supports_discarded_events_with_clock_snapshots_without_default_clock_class_raises( + self, + ): + with self.assertRaisesRegex( + ValueError, + "cannot have no default clock class, but have default clock snapshots for discarded event messages", + ): + self._tc.create_stream_class( + supports_discarded_events=True, + discarded_events_have_default_clock_snapshots=True, + ) + + self.assertEqual(len(self._tc), 0) + def test_supports_discarded_packets_without_cs(self): sc = self._tc.create_stream_class( default_clock_class=self._cc, @@ -419,6 +421,21 @@ class StreamClassTestCase(unittest.TestCase): self.assertEqual(len(self._tc), 0) + def test_supports_discarded_packets_with_clock_snapshots_without_default_clock_class_raises( + self, + ): + with self.assertRaisesRegex( + ValueError, + "cannot have no default clock class, but have default clock snapshots for discarded packet messages", + ): + self._tc.create_stream_class( + supports_packets=True, + supports_discarded_packets=True, + discarded_packets_have_default_clock_snapshots=True, + ) + + self.assertEqual(len(self._tc), 0) + def test_trace_class(self): sc = self._tc.create_stream_class() self.assertEqual(sc.trace_class.addr, self._tc.addr) @@ -442,12 +459,12 @@ class StreamClassTestCase(unittest.TestCase): sc, _, _ = self._create_stream_class_with_event_classes() with self.assertRaisesRegex(TypeError, "'str' is not an 'int' object"): - sc['event23'] + sc["event23"] def test_getitem_wrong_key(self): sc, _, _ = self._create_stream_class_with_event_classes() - with self.assertRaisesRegex(KeyError, '19'): + with self.assertRaisesRegex(KeyError, "19"): sc[19] def test_len(self): @@ -462,5 +479,5 @@ class StreamClassTestCase(unittest.TestCase): self.assertEqual(ec_ids, [17, 23]) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main()