Imagine that there is a models.py
file which have update
and bulk_update
methods
...
@staticmethod
def bulk_update(self, ids):
for id in ids:
Foo.objects.get(id=id).update()
def update(self):
pass
...
Not imagine that we have tests.py
file, where we want to mock
the update
method. The problem is that whatever I do, mock_update
always calls original update
instead of a mocked one.
TRY #1:
# NOT WORKING
@mock.patch('models.Foo.update')
class FooTestCase(TestCase):
def test_foo(self):
Foo.bulk_update([1,2,3])
Aucun commentaire:
Enregistrer un commentaire