Skip to content

Commit

Permalink
Add tests for Mapping key type-hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaTolpikin committed Feb 4, 2025
1 parent 6ccff0c commit 4bb37ed
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/core/test_config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass
from enum import Enum
from typing import Optional, List, Union
from typing import Optional, List, Union, Dict

import pytest

Expand Down Expand Up @@ -121,6 +121,16 @@ def raise_error(_):
from_dict(X, {"i": 1}, config=Config(type_hooks={int: raise_error}))


def test_from_dict_with_type_hooks_and_generic_mapping():
@dataclass
class X:
d: Dict[str, str]

result = from_dict(X, {"d": {"B": "TEST"}}, config=Config(type_hooks={str: str.lower}))

assert result == X(d={"b": "test"})


def test_from_dict_with_forward_reference():
@dataclass
class X:
Expand Down

0 comments on commit 4bb37ed

Please sign in to comment.