Changeset 6a3a664 in rtems-central


Ignore:
Timestamp:
Jul 27, 2020, 5:08:34 AM (2 weeks ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
fd31f9d
Parents:
1cf2bec
Message:

items: Improve ItemCache? exception message

Location:
rtemsspec
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • rtemsspec/items.py

    r1cf2bec r6a3a664  
    235235        """ Initializes the list of links to parents of this items. """
    236236        for data in self._data["links"]:
    237             link = Link(item_cache[self.to_abs_uid(data["uid"])], data)
    238             self._links_to_parents.append(link)
     237            try:
     238                link = Link(item_cache[self.to_abs_uid(data["uid"])], data)
     239                self._links_to_parents.append(link)
     240            except KeyError as err:
     241                msg = (f"item '{self.uid}' links "
     242                       f"to non-existing item '{data['uid']}'")
     243                raise KeyError(msg) from err
    239244
    240245    def add_link_to_child(self, link: Link):
  • rtemsspec/tests/test_items_itemcache.py

    r1cf2bec r6a3a664  
    6161    item_cache_3 = ItemCache(config)
    6262    assert item_cache_3["/d/c"]["v"] == "x"
     63
     64
     65def test_load_link_error(tmpdir):
     66    config = create_item_cache_config_and_copy_spec(tmpdir,
     67                                                    "spec-item-cache-2")
     68    with pytest.raises(
     69            KeyError,
     70            match=r"^\"item '/a' links to non-existing item 'nix'\"$"):
     71        ItemCache(config)
    6372
    6473
Note: See TracChangeset for help on using the changeset viewer.