# Path: tests/_compat.py
# def change_type_param(cl, new_params):
# def change_type_param(cl, new_params):


from typing import Dict, Generic, List, Optional, TypeVar, Union
from attr import asdict, attrs, define
from cattr._compat import Protocol, is_py39_plus
from cattr._generics import deep_copy_with
from cattrs import Converter, GenConverter
from cattrs.errors import StructureHandlerNotFoundError
from ._compat import Dict_origin, List_origin
import pytest




T = TypeVar("T")
T2 = TypeVar("T2")


def test_deep_copy():
    """Test the deep copying of generic parameters."""
    mapping = {T.__name__: int}
    assert deep_copy_with(Optional[T], mapping) == Optional[int]
    assert (
        deep_copy_with(List_origin[Optional[T]], mapping) == List_origin[Optional[int]]
    )
    mapping = {T.__name__: int, T2.__name__: str}
    assert (
        deep_copy_with(Dict_origin[T2, List_origin[Optional[T]]], mapping)

# Path: tests/_compat.py
# def change_type_param(cl, new_params):
# def change_type_param(cl, new_params):


# Path: tests/test_generics.py
from typing import Dict, Generic, List, Optional, TypeVar, Union
from attr import asdict, attrs, define
from cattr._compat import Protocol, is_py39_plus
from cattr._generics import deep_copy_with
from cattrs import Converter, GenConverter
from cattrs.errors import StructureHandlerNotFoundError
from ._compat import Dict_origin, List_origin
import pytest





T = TypeVar("T")
T2 = TypeVar("T2")


def test_deep_copy():
    """Test the deep copying of generic parameters."""
    mapping = {T.__name__: int}
    assert deep_copy_with(Optional[T], mapping) == Optional[int]
    assert (
        deep_copy_with(List_origin[Optional[T]], mapping) == List_origin[Optional[int]]
    )
    mapping = {T.__name__: int, T2.__name__: str}
    assert (
        deep_copy_with(Dict_origin[T2, List_origin[Optional[T]]], mapping)

        == Dict_origin[str, List_origin[Optional[int]]]