Move to kernel style SPDX license identifiers
[babeltrace.git] / tests / bindings / python / bt2 / test_stream_class.py
index be73d46e4dafac2c842023ea971ba06d352579fe..9010dcd4c7d68e6755f26a8e7488358b6def47c2 100644 (file)
@@ -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 run_in_component_init
@@ -62,6 +49,8 @@ class StreamClassTestCase(unittest.TestCase):
         with self.assertRaisesRegex(TypeError, "'int' is not a 'str' object"):
             self._tc.create_stream_class(name=17)
 
+        self.assertEqual(len(self._tc), 0)
+
     def test_create_packet_context_field_class(self):
         fc = self._tc.create_structure_field_class()
         sc = self._tc.create_stream_class(
@@ -77,7 +66,11 @@ class StreamClassTestCase(unittest.TestCase):
             TypeError,
             "'int' is not a '<class 'bt2.field_class._StructureFieldClass'>' object",
         ):
-            self._tc.create_stream_class(packet_context_field_class=22)
+            self._tc.create_stream_class(
+                packet_context_field_class=22, supports_packets=True
+            )
+
+        self.assertEqual(len(self._tc), 0)
 
     def test_create_invalid_packet_context_field_class_no_packets(self):
         fc = self._tc.create_structure_field_class()
@@ -88,6 +81,8 @@ class StreamClassTestCase(unittest.TestCase):
         ):
             self._tc.create_stream_class(packet_context_field_class=fc)
 
+        self.assertEqual(len(self._tc), 0)
+
     def test_create_event_common_context_field_class(self):
         fc = self._tc.create_structure_field_class()
         sc = self._tc.create_stream_class(event_common_context_field_class=fc)
@@ -104,6 +99,8 @@ class StreamClassTestCase(unittest.TestCase):
         ):
             self._tc.create_stream_class(event_common_context_field_class=22)
 
+        self.assertEqual(len(self._tc), 0)
+
     def test_create_default_clock_class(self):
         sc = self._tc.create_stream_class(default_clock_class=self._cc)
         self.assertEqual(sc.default_clock_class.addr, self._cc.addr)
@@ -115,6 +112,8 @@ class StreamClassTestCase(unittest.TestCase):
         ):
             self._tc.create_stream_class(default_clock_class=12)
 
+        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})
@@ -125,6 +124,8 @@ class StreamClassTestCase(unittest.TestCase):
         ):
             self._tc.create_stream_class(user_attributes=object())
 
+        self.assertEqual(len(self._tc), 0)
+
     def test_create_invalid_user_attributes_value_type(self):
         with self.assertRaisesRegex(
             TypeError,
@@ -132,6 +133,8 @@ class StreamClassTestCase(unittest.TestCase):
         ):
             self._tc.create_stream_class(user_attributes=23)
 
+        self.assertEqual(len(self._tc), 0)
+
     def test_automatic_stream_ids(self):
         sc = self._tc.create_stream_class(assigns_automatic_stream_id=True)
         self.assertTrue(sc.assigns_automatic_stream_id)
@@ -148,6 +151,14 @@ class StreamClassTestCase(unittest.TestCase):
         ):
             self._trace.create_stream(sc, id=123)
 
+        self.assertEqual(len(self._trace), 0)
+
+    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.assertEqual(len(self._tc), 0)
+
     def test_no_automatic_stream_ids(self):
         sc = self._tc.create_stream_class(assigns_automatic_stream_id=False)
         self.assertFalse(sc.assigns_automatic_stream_id)
@@ -165,6 +176,8 @@ class StreamClassTestCase(unittest.TestCase):
         ):
             self._trace.create_stream(sc)
 
+        self.assertEqual(len(self._trace), 0)
+
     def test_automatic_event_class_ids(self):
         sc = self._tc.create_stream_class(assigns_automatic_event_class_id=True)
         self.assertTrue(sc.assigns_automatic_event_class_id)
@@ -182,6 +195,14 @@ class StreamClassTestCase(unittest.TestCase):
         ):
             sc.create_event_class(id=123)
 
+        self.assertEqual(len(sc), 0)
+
+    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.assertEqual(len(self._tc), 0)
+
     def test_no_automatic_event_class_ids(self):
         sc = self._tc.create_stream_class(assigns_automatic_event_class_id=False)
         self.assertFalse(sc.assigns_automatic_event_class_id)
@@ -199,6 +220,8 @@ class StreamClassTestCase(unittest.TestCase):
         ):
             sc.create_event_class()
 
+        self.assertEqual(len(sc), 0)
+
     def test_supports_packets_without_cs(self):
         sc = self._tc.create_stream_class(
             default_clock_class=self._cc, supports_packets=True
@@ -233,6 +256,8 @@ class StreamClassTestCase(unittest.TestCase):
                 default_clock_class=self._cc, supports_packets=23
             )
 
+        self.assertEqual(len(self._tc), 0)
+
     def test_packets_have_begin_default_cs_raises_type_error(self):
         with self.assertRaisesRegex(TypeError, "'int' is not a 'bool' object"):
             self._tc.create_stream_class(
@@ -240,12 +265,16 @@ class StreamClassTestCase(unittest.TestCase):
                 packets_have_beginning_default_clock_snapshot=23,
             )
 
+        self.assertEqual(len(self._tc), 0)
+
     def test_packets_have_end_default_cs_raises_type_error(self):
         with self.assertRaisesRegex(TypeError, "'int' is not a 'bool' object"):
             self._tc.create_stream_class(
                 default_clock_class=self._cc, packets_have_end_default_clock_snapshot=23
             )
 
+        self.assertEqual(len(self._tc), 0)
+
     def test_does_not_support_packets_raises_with_begin_cs(self):
         with self.assertRaisesRegex(
             ValueError,
@@ -256,6 +285,8 @@ class StreamClassTestCase(unittest.TestCase):
                 packets_have_beginning_default_clock_snapshot=True,
             )
 
+        self.assertEqual(len(self._tc), 0)
+
     def test_does_not_support_packets_raises_with_end_cs(self):
         with self.assertRaisesRegex(
             ValueError,
@@ -266,6 +297,8 @@ class StreamClassTestCase(unittest.TestCase):
                 packets_have_end_default_clock_snapshot=True,
             )
 
+        self.assertEqual(len(self._tc), 0)
+
     def test_supports_discarded_events_without_cs(self):
         sc = self._tc.create_stream_class(
             default_clock_class=self._cc, supports_discarded_events=True
@@ -288,6 +321,8 @@ class StreamClassTestCase(unittest.TestCase):
                 default_clock_class=self._cc, supports_discarded_events=23
             )
 
+        self.assertEqual(len(self._tc), 0)
+
     def test_discarded_events_have_default_cs_raises_type_error(self):
         with self.assertRaisesRegex(TypeError, "'int' is not a 'bool' object"):
             self._tc.create_stream_class(
@@ -295,6 +330,8 @@ class StreamClassTestCase(unittest.TestCase):
                 discarded_events_have_default_clock_snapshots=23,
             )
 
+        self.assertEqual(len(self._tc), 0)
+
     def test_does_not_support_discarded_events_raises_with_cs(self):
         with self.assertRaisesRegex(
             ValueError,
@@ -305,6 +342,8 @@ class StreamClassTestCase(unittest.TestCase):
                 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,
@@ -332,6 +371,8 @@ class StreamClassTestCase(unittest.TestCase):
                 default_clock_class=self._cc, supports_discarded_packets=True
             )
 
+        self.assertEqual(len(self._tc), 0)
+
     def test_supports_discarded_packets_raises_type_error(self):
         with self.assertRaisesRegex(TypeError, "'int' is not a 'bool' object"):
             self._tc.create_stream_class(
@@ -340,6 +381,8 @@ class StreamClassTestCase(unittest.TestCase):
                 supports_packets=True,
             )
 
+        self.assertEqual(len(self._tc), 0)
+
     def test_discarded_packets_have_default_cs_raises_type_error(self):
         with self.assertRaisesRegex(TypeError, "'int' is not a 'bool' object"):
             self._tc.create_stream_class(
@@ -348,6 +391,8 @@ class StreamClassTestCase(unittest.TestCase):
                 supports_packets=True,
             )
 
+        self.assertEqual(len(self._tc), 0)
+
     def test_does_not_support_discarded_packets_raises_with_cs(self):
         with self.assertRaisesRegex(
             ValueError,
@@ -359,6 +404,8 @@ class StreamClassTestCase(unittest.TestCase):
                 supports_packets=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)
This page took 0.025327 seconds and 4 git commands to generate.