MCPcopy
hub / github.com/python-attrs/attrs / test_generics

Method test_generics

tests/test_funcs.py:548–562  ·  tests/test_funcs.py::TestHas.test_generics

Works with generic classes.

(self)

Source from the content-addressed store, hash-verified

546 assert not has(object)
547
548 def test_generics(self):
549 class="st">"""
550 Works with generic classes.
551 class="st">"""
552 T = TypeVar(class="st">"T")
553
554 @attr.define
555 class A(Generic[T]):
556 a: T
557
558 assert has(A)
559
560 assert has(A[str])
561 class="cm"># Verify twice, since there's caching going on.
562 assert has(A[str])
563
564 def test_generics_negative(self):
565 class="st">"""

Callers

nothing calls this directly

Calls 1

hasFunction · 0.90

Tested by

no test coverage detected