Skip to content

Commit

Permalink
Increase coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Fatal1ty committed Apr 20, 2024
1 parent 5711940 commit 0fa3717
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from mashumaro.codecs import BasicDecoder
from mashumaro.core.meta.helpers import type_name
from mashumaro.exceptions import (
ExtraKeysError,
InvalidFieldValue,
MissingDiscriminatorError,
MissingField,
Expand Down Expand Up @@ -190,3 +191,16 @@ class MyClass(DataClassDictMixin):
f"Argument for {type_name(MyClass)}."
f"__mashumaro_from_dict__ method should be a dict instance"
)


def test_extra_keys_error():
@dataclass
class MyClass(DataClassDictMixin):
x: str

class Config:
forbid_extra_keys = True

with pytest.raises(ExtraKeysError) as exc_info:
MyClass.from_dict({"x": "x", "y": "y"})
assert str(exc_info.value).endswith(".MyClass: y")

0 comments on commit 0fa3717

Please sign in to comment.