I have following code:
pkg1/mock_class.py:
class A:
def ma(self):
print(' class_A')
class B:
def __init__(self):
self.var = 'vvv'
def mb(self):
a = A()
print('class_B')
a.ma()
and test code:
from unittest import mock
import pytest
from pkg1.mock_class import B
@pytest.fixture(scope='class')
def mockA():
with mock.patch('pkg1.mock_class.A'):
yield
class TestB:
def test_b(self, mockA):
b = B()
b.mb()
I want to mock whole class A () using fixture and i would like to be able to configure some return values probably using parametrization in future.
Basic - just mocking/patching as implemented above is not working class B is mocked and i don't understand why.
Thanks for advice.
Jano