M src/groceries/cli/main.py => src/groceries/cli/main.py +2 -2
@@ 142,7 142,7 @@ def modify(ctx, item_name, section, priority, shop):
try:
grocery_list.update_item(item_name, **fields)
- except ValueError as err:
+ except LookupError as err:
raise click.ClickException(err)
else:
click.echo("\n".join(messages))
@@ 157,7 157,7 @@ def remove(ctx, item_name):
try:
grocery_list.delete_item(item_name)
- except ValueError as err:
+ except LookupError as err:
raise click.ClickException(err)
else:
click.echo(f"{item_name!r} removed from grocery list.")
M src/groceries/model.py => src/groceries/model.py +2 -2
@@ 39,7 39,7 @@ class GroceryList:
item = self._repo.select(item_name)
if item is None:
- raise ValueError(f"{item_name!r} not found in grocery list.")
+ raise LookupError(f"{item_name!r} not found in grocery list.")
updated_item = attr.evolve(item, **fields)
self._repo.update(item_name, updated_item)
@@ 48,4 48,4 @@ class GroceryList:
try:
self._repo.delete(item_name)
except LookupError:
- raise ValueError(f"{item_name!r} not found in grocery list.")
+ raise LookupError(f"{item_name!r} not found in grocery list.")
M tests/test_backend_integrations.py => tests/test_backend_integrations.py +2 -2
@@ 76,7 76,7 @@ def test_update(grocery_list, items):
def test_update_unknown(grocery_list, items):
- with pytest.raises(ValueError) as err:
+ with pytest.raises(LookupError) as err:
grocery_list.update_item("jabberwocky", section="slithy tove")
assert err.match("'jabberwocky' not found in grocery list.")
@@ 90,7 90,7 @@ def test_delete(grocery_list, items):
def test_delete_unknown(grocery_list, items):
- with pytest.raises(ValueError) as err:
+ with pytest.raises(LookupError) as err:
grocery_list.delete_item("jabberwocky")
assert err.match("'jabberwocky' not found in grocery list.")