I've got a function, accounts.tasks.assign_agent. During tests, I'd like to mock this function so that it doesn't actually get called for all of the tests, because it's very slow.
I've tried mocking every test method of my TestCase class, I've also tried mocking the setUp method, something like this:
from unittest import TestCase as BaseTestCase
import mock
class TestCase(BaseTestCase):
@mock.patch('accounts.tasks.assign_agent')
def setUp(self, assign_agent_mock):
... # stuff
@mock.patch('accounts.tasks.assign_agent')
def test_stuff(self, assign_agent_mock):
... # stuff
For some of the methods in the class, this method works. However, there are two methods that fail because they are trying to call the real assign_agent and failing.
What could cause the mock.patch to fail for these methods?
Aucun commentaire:
Enregistrer un commentaire