Parcourir la source

[trac671] raise a DataNotFoundError instead of print(error)

Jelte Jansen il y a 14 ans
Parent
commit
d27da40718

+ 2 - 2
src/lib/python/isc/config/config_data.py

@@ -461,8 +461,8 @@ class MultiConfigData:
                 spec_part_list = spec_part['list_item_spec']
                 list_value, status = self.get_value(identifier)
                 if list_value is None:
-                    print("Error: identifier '%s' not found" % identifier)
-                    return
+                    raise isc.cc.data.DataNotFoundError(identifier)
+
                 if type(list_value) != list:
                     # the identifier specified a single element
                     self._append_value_item(result, spec_part_list, identifier, all)

+ 2 - 2
src/lib/python/isc/config/tests/config_data_test.py

@@ -465,8 +465,8 @@ class TestMultiConfigData(unittest.TestCase):
 
         module_spec = isc.config.module_spec_from_file(self.data_path + os.sep + "spec24.spec")
         self.mcd.set_specification(module_spec)
-        maps = self.mcd.get_value_maps("/Spec24/item")
-        self.assertEqual([], maps)
+        self.assertRaises(isc.cc.data.DataNotFoundError,
+                          self.mcd.get_value_maps, "/Spec24/item", 4)
         self.mcd._set_current_config({ "Spec24": { "item": [] } })
         maps = self.mcd.get_value_maps("/Spec24/item")
         self.assertEqual([{'default': False, 'modified': False, 'name': 'Spec24/item', 'type': 'list', 'value': []}], maps)