@@ -16,13 +16,12 @@ class Foo(Generic[T], GenericMixin):
1616 value : T
1717
1818 foo = Foo [str ]()
19- assert foo .type_var == str
2019 assert foo .type_vars == {T : str }
2120
2221 invalid = Foo ()
2322
2423 with pytest .raises (expected_exception = AssertionError ) as err :
25- invalid .type_var
24+ invalid .type_vars
2625
2726 assert f'You need to instantiate this class with type parameters! Example: Foo[int]()' in err .value .args [0 ]
2827
@@ -34,17 +33,12 @@ class Foo(Generic[T, U], GenericMixin):
3433
3534 foo = Foo [str , int ]()
3635
37- with pytest .raises (expected_exception = ValueError ) as err :
38- foo .type_var
39-
40- assert 'You have multiple type parameters. Please use "type_vars" instead of "type_var".' in err .value .args [0 ]
41-
4236 assert foo .type_vars == {T : str , U : int }
4337
4438 invalid = Foo ()
4539
4640 with pytest .raises (expected_exception = AssertionError ) as err :
47- invalid .type_var
41+ invalid .type_vars
4842
4943 assert 'You need to instantiate this class with type parameters! Example: Foo[int]()' in err .value .args [0 ]
5044
@@ -56,15 +50,15 @@ class Foo(GenericMixin):
5650 invalid = Foo ()
5751
5852 with pytest .raises (expected_exception = AssertionError ) as err :
59- invalid .type_var
53+ invalid .type_vars
6054
6155 assert err .value .args [0 ] == 'Foo is not a generic class. To make it generic, declare it like: class Foo(Generic[T], GenericMixin):...'
6256
6357
64- def test_call_type_var_in_constructor ():
58+ def test_call_type_vars_in_constructor ():
6559 class Foo (Generic [T ], GenericMixin ):
6660 def __init__ (self ) -> None :
67- self .x = self .type_var ()
61+ self .x = self .type_vars
6862
6963 with pytest .raises (expected_exception = AssertionError ) as err :
7064 Foo [str ]()
0 commit comments