Skip to content

Commit c5795ad

Browse files
committed
Put everything under test_generics_649.py
1 parent 8769ecb commit c5795ad

3 files changed

Lines changed: 25 additions & 24 deletions

File tree

tests/generics.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

tests/test_generics.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from cattrs.gen._generics import generate_mapping
1212

1313
from ._compat import Dict_origin, List_origin, is_py310_plus, is_py311_plus
14-
from .generics import GenericClass
1514

1615
T = TypeVar("T")
1716
T2 = TypeVar("T2")
@@ -359,12 +358,3 @@ class GenericEntity(GenericProtocol[int]):
359358
assert generate_mapping(GenericEntity) == {"T": int}
360359

361360
assert converter.structure({"a": 1}, GenericEntity) == GenericEntity(1)
362-
363-
364-
def test_generics_with_stringified_annotations():
365-
"""Type resolution works with stringified annotations."""
366-
converter = Converter()
367-
inst = GenericClass(42)
368-
dct = converter.unstructure(inst, unstructure_as=GenericClass[int])
369-
assert dct == {"t": 42}
370-
assert converter.structure(dct, GenericClass[int])

tests/test_generics_649.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""Tests for PEP 649 (Deferred Evaluation Of Annotations Using Descriptors)."""
2+
3+
from __future__ import annotations
4+
5+
from typing import Generic, TypeVar
6+
7+
from attrs import define
8+
9+
from cattrs import Converter
10+
11+
T = TypeVar("T")
12+
13+
14+
@define
15+
class GenericClass(Generic[T]):
16+
t: T
17+
18+
19+
def test_generics_with_stringified_annotations():
20+
"""Type resolution works with stringified annotations."""
21+
converter = Converter()
22+
inst = GenericClass(42)
23+
dct = converter.unstructure(inst, unstructure_as=GenericClass[int])
24+
assert dct == {"t": 42}
25+
assert converter.structure(dct, GenericClass[int])

0 commit comments

Comments
 (0)