Skip to content

Commit

Permalink
Add test for various ClassVars
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Feb 19, 2021
1 parent 0c16aec commit 0d5ecdc
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/test_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import attr

from attr._make import _is_class_var
from attr.exceptions import UnannotatedAttributeError


Expand Down Expand Up @@ -604,3 +605,19 @@ class C:

with pytest.raises(NameError):
typing.get_type_hints(C.__init__)


@pytest.mark.parametrize(
"annot",
[
typing.ClassVar,
"typing.ClassVar",
"'typing.ClassVar[dict]'",
"t.ClassVar[int]",
],
)
def test_is_class_var(annot):
"""
ClassVars are detected, even if they're a string or quoted.
"""
assert _is_class_var(annot)

0 comments on commit 0d5ecdc

Please sign in to comment.