Coverage for pyfields/tests/issues/test_issue_12.py: 100%

12 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-11-06 16:35 +0000

1import inspect 

2 

3from pyfields import field 

4from pyfields.core import NativeField 

5 

6 

7def test_class_access_and_autocomplete(): 

8 """ test that https://github.com/smarie/python-pyfields/issues/12 is resolved """ 

9 class Foo: 

10 a = field(type_hint=int, default=1) 

11 

12 assert Foo.a.name == 'a' 

13 assert isinstance(Foo.a, NativeField) 

14 assert dict(inspect.getmembers(Foo))['a'] == Foo.a 

15 

16 f = Foo() 

17 assert f.a == 1 

18 

19 Foo.a = 5