Пример #1
0
    def build_from_element(element):
        items = dict(element.items())
        child_items = dict(
            (child.tag, build_from_element(child)) for child in element)

        config.has_duplicate_keys(child_items, items, safe)
        items.update(child_items)
        if element.text:
            if 'value' in items and safe:
                msg = "%s has tag with child or attribute named value."
                raise errors.ConfigurationError(msg % filename)
            items['value'] = element.text
        return items
Пример #2
0
    def build_from_element(element):
        items = dict(element.items())
        child_items = dict(
            (child.tag, build_from_element(child))
            for child in element)

        config.has_duplicate_keys(child_items, items, safe)
        items.update(child_items)
        if element.text:
            if 'value' in items and safe:
                msg = "%s has tag with child or attribute named value."
                raise errors.ConfigurationError(msg % filename)
            items['value'] = element.text
        return items
 def test_has_duplicate_keys_no_raise(self):
     config_data = dict(mind=123)
     assert config.has_duplicate_keys(config_data, self.base_conf, False)
 def test_has_dupliacte_keys_false(self):
     config_data = dict(unique_keys=123)
     assert not config.has_duplicate_keys(config_data, self.base_conf, True)
     assert not config.has_duplicate_keys(config_data, self.base_conf,
                                          False)
Пример #5
0
 def test_has_duplicate_keys_no_raise(self):
     config_data = dict(mind=123)
     assert config.has_duplicate_keys(config_data, self.base_conf, False)
Пример #6
0
 def test_has_dupliacte_keys_false(self):
     config_data = dict(unique_keys=123)
     assert not config.has_duplicate_keys(config_data, self.base_conf, True)
     assert not config.has_duplicate_keys(config_data, self.base_conf, False)