I'm writing a test and I want to mock a list that is located in init.py, meaning not under a class. The object reference is: project/app/management/commands/__init__.py
and __init__.py
looks something like:
my_list_of_dict = [
{
'name': 'option1',
'vesion': 0,
},
{
'name': 'option1',
'vesion': 0,
}
]
If it was under a class I would do something like -
@mock.patch.object(Class, 'my_list_of_dict')
but it isn't the case.
I tried something like
@mock.patch('project.app.management.commands.my_list_of_dict')
def test(self, mock_list):
mock_list.return_value = [{.....}]
But it didn't work.
Aucun commentaire:
Enregistrer un commentaire