Skip to content

Commit 51a25fd

Browse files
committed
refactor: use more appropriate exception for invalid global fields
1 parent b9b13c3 commit 51a25fd

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/_algopy_testing/context_helpers/ledger_context.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,16 +403,14 @@ def patch_global_fields(self, **global_fields: typing.Unpack[GlobalFields]) -> N
403403
**global_fields: The fields to patch.
404404
405405
Raises:
406-
AttributeError: If invalid fields are provided.
406+
ValueError: If invalid fields are provided.
407407
"""
408408
from _algopy_testing.op.global_values import GlobalFields
409409

410410
invalid_keys = global_fields.keys() - GlobalFields.__annotations__.keys()
411411

412412
if invalid_keys:
413-
raise AttributeError(
414-
f"Invalid field(s) found during patch for `Global`: {', '.join(invalid_keys)}"
415-
)
413+
raise ValueError(f"Invalid Global fields: {', '.join(invalid_keys)}")
416414

417415
self._global_fields.update(global_fields)
418416

tests/test_context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_patch_global_fields() -> None:
3030
assert context.ledger._global_fields["min_txn_fee"] == 100
3131
assert context.ledger._global_fields["min_balance"] == 10
3232

33-
with pytest.raises(AttributeError, match="InvalidField"):
33+
with pytest.raises(ValueError, match="InvalidField"):
3434
context.ledger.patch_global_fields(InvalidField=123) # type: ignore # noqa: PGH003
3535

3636

0 commit comments

Comments
 (0)