Coverage for pyfields/tests/issues/_test_py36.py: 97%
30 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-11-06 16:35 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-11-06 16:35 +0000
1# Authors: Sylvain Marie <sylvain.marie@se.com>
2#
3# Copyright (c) Schneider Electric Industries, 2019. All right reserved.
5from pyfields import field, init_fields, autofields, autoclass
8def test_issue_51():
9 class A:
10 f: str = field(check_type=True, default=None, nonable=True)
12 @init_fields
13 def __init__(self):
14 pass
16 return A
19def test_issue_67():
20 @autofields
21 class Frog:
22 another: int = 1
24 @property
25 def balh(self):
26 print('asd')
28 return Frog
31def test_issue_73():
32 class Foo:
33 bar: 'Foo' = field(check_type=True, nonable=True)
34 return Foo
37class A:
38 bar: 'B' = field(check_type=True, nonable=True)
40class B:
41 bar: 'A' = field(check_type=True, nonable=True)
44def test_issue_73_cross_ref():
45 # note: we have to define the classes outside the function for the cross-ref to work
46 # indeed typing.get_type_hints() will only access the globals of the defining module
47 return A, B
50def test_issue_81():
52 # note that the issue comes from autofields actually, but it was detected using autoclass
54 @autoclass
55 class A:
56 a: int = 1
58 @autoclass
59 class B(A):
60 b = 0
62 return A, B