I am working on writing unit tests for my code and I am stuck mocking functions. My code base is similar to the example given below
app/
file/
core/
conversion.py
helper/
common.py
test/
file/
conversion_test.py
conversion.py contains
class Convertor:
def __init__(self, client_svc, common_svc):
self.clientSvc = client_svc
self.commonSvc = common_svc
def my_function(self, inputs):
result = self.commonSvc.read(inputs)
return result
common.py contains
class CommonReader:
def __init__(self, args):
self.path = args
def read(self, inputs):
# Some code
return results
and conversion_test.py contains
class testConvertor:
conv = Convertor(client_svc, common_svc)
def test_my_function(self, mocker):
mocker.patch('app.file.core.convertion.CommonReader.read',
return_value=some_output)
result = self.conv.my_function(inputs)
assert result == some_result
But I am getting the following here
ModuleNotFoundError: No module named 'app.file.core.convertion.CommonReader'; 'app.file.core.convertion' is not a package
What am I doing wrong here?