bt2: raise an exception if an AutoSourceComponentSpec produces no component
[babeltrace.git] / tests / bindings / python / bt2 / test_field_class.py
index 2b05f0096cfab2bc8213d98834c6bc2033e0b377..4d56b467eb1c650c8ae9425d4103cf3cc61e5e83 100644 (file)
@@ -16,7 +16,6 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #
 
-import bt2.field
 import unittest
 import bt2
 import collections
@@ -132,7 +131,7 @@ class _EnumerationFieldClassTestCase(_TestIntegerFieldClassProps):
             self._fc.add_mapping('allo', 'meow')
 
     def test_add_mapping_dup_label(self):
-        with self.assertRaises(bt2.Error):
+        with self.assertRaises(ValueError):
             self._fc.add_mapping('a', self._ranges1)
             self._fc.add_mapping('a', self._ranges2)
 
@@ -263,7 +262,7 @@ class _TestElementContainer:
         sub_fc1 = self._tc.create_string_field_class()
         sub_fc2 = self._tc.create_string_field_class()
 
-        with self.assertRaises(bt2.Error):
+        with self.assertRaises(ValueError):
             self._append_element_method(self._fc, 'yes', sub_fc1)
             self._append_element_method(self._fc, 'yes', sub_fc2)
 
@@ -371,12 +370,8 @@ class _TestElementContainer:
 
 
 class StructureFieldClassTestCase(_TestElementContainer, unittest.TestCase):
-    _append_element_method = staticmethod(
-        bt2.field_class._StructureFieldClass.append_member
-    )
-    _at_index_method = staticmethod(
-        bt2.field_class._StructureFieldClass.member_at_index
-    )
+    _append_element_method = staticmethod(bt2._StructureFieldClass.append_member)
+    _at_index_method = staticmethod(bt2._StructureFieldClass.member_at_index)
 
     def _create_default_fc(self):
         return self._tc.create_structure_field_class()
@@ -386,10 +381,10 @@ class VariantFieldClassWithoutSelectorTestCase(
     _TestElementContainer, unittest.TestCase
 ):
     _append_element_method = staticmethod(
-        bt2.field_class._VariantFieldClassWithoutSelector.append_option
+        bt2._VariantFieldClassWithoutSelector.append_option
     )
     _at_index_method = staticmethod(
-        bt2.field_class._VariantFieldClassWithoutSelector.option_at_index
+        bt2._VariantFieldClassWithoutSelector.option_at_index
     )
 
     def _create_default_fc(self):
@@ -446,7 +441,7 @@ class _VariantFieldClassWithSelectorTestCase:
         sub_fc1 = self._tc.create_string_field_class()
         sub_fc2 = self._tc.create_string_field_class()
 
-        with self.assertRaises(bt2.Error):
+        with self.assertRaises(ValueError):
             self._fc.append_option('yes', sub_fc1, self._ranges1)
             self._fc.append_option('yes', sub_fc2, self._ranges2)
 
@@ -617,20 +612,18 @@ class _VariantFieldClassWithSelectorTestCase:
 
         self.assertEqual(len(path_items), 3)
 
-        self.assertIsInstance(path_items[0], bt2.field_path._IndexFieldPathItem)
+        self.assertIsInstance(path_items[0], bt2._IndexFieldPathItem)
         self.assertEqual(path_items[0].index, 1)
 
-        self.assertIsInstance(
-            path_items[1], bt2.field_path._CurrentArrayElementFieldPathItem
-        )
+        self.assertIsInstance(path_items[1], bt2._CurrentArrayElementFieldPathItem)
 
-        self.assertIsInstance(path_items[2], bt2.field_path._IndexFieldPathItem)
+        self.assertIsInstance(path_items[2], bt2._IndexFieldPathItem)
         self.assertEqual(path_items[2].index, 0)
 
     def test_selector_field_path_root_scope(self):
         self._fill_default_fc_for_field_path_test()
         self.assertEqual(
-            self._fc.selector_field_path.root_scope, bt2.field_path.Scope.PACKET_CONTEXT
+            self._fc.selector_field_path.root_scope, bt2.FieldPathScope.PACKET_CONTEXT
         )
 
 
@@ -745,20 +738,18 @@ class DynamicArrayFieldClassTestCase(unittest.TestCase):
 
         self.assertEqual(len(path_items), 3)
 
-        self.assertIsInstance(path_items[0], bt2.field_path._IndexFieldPathItem)
+        self.assertIsInstance(path_items[0], bt2._IndexFieldPathItem)
         self.assertEqual(path_items[0].index, 1)
 
-        self.assertIsInstance(
-            path_items[1], bt2.field_path._CurrentArrayElementFieldPathItem
-        )
+        self.assertIsInstance(path_items[1], bt2._CurrentArrayElementFieldPathItem)
 
-        self.assertIsInstance(path_items[2], bt2.field_path._IndexFieldPathItem)
+        self.assertIsInstance(path_items[2], bt2._IndexFieldPathItem)
         self.assertEqual(path_items[2].index, 2)
 
     def test_field_path_root_scope(self):
         fc = self._create_field_class_for_field_path_test()
         self.assertEqual(
-            fc.length_field_path.root_scope, bt2.field_path.Scope.PACKET_CONTEXT
+            fc.length_field_path.root_scope, bt2.FieldPathScope.PACKET_CONTEXT
         )
 
     def test_create_invalid_field_class(self):
This page took 0.02693 seconds and 4 git commands to generate.