I have the following class A
to be tested.
aaa.py
def get_c():
print('call external modules to get c from some expensive I/O')
return 'something'
@dataclass
class A:
c: ClassVar[C] = get_c() # get_c() shouldn't be run in the test code
In a test code, I assign A.c
to some constants. However, get_c()
was still called.
from aaa import A
@pytest.fixture
def sut()
A.c = {'a':0}
yield A()
def test_1(sut):
''''''
How to prevent get_c()
from being called?