feat: add detail if get_obj_by_attr raise StopIteration (#40)

This commit is contained in:
d3vyce
2026-02-07 17:39:07 +01:00
committed by GitHub
parent d526969d0e
commit baa9711665
2 changed files with 12 additions and 4 deletions

View File

@@ -744,8 +744,11 @@ class TestGetObjByAttr:
assert user.username == "alice"
def test_no_match_raises_stop_iteration(self):
"""Raises StopIteration when no object matches."""
with pytest.raises(StopIteration):
"""Raises StopIteration with contextual message when no object matches."""
with pytest.raises(
StopIteration,
match="No object with name=nonexistent found in fixture 'roles'",
):
get_obj_by_attr(self.roles, "name", "nonexistent")
def test_no_match_on_wrong_value_type(self):