How to mock a function in a django custom command?
How can I mock foo in order to have it NOT called?
Here's my latest attempt:
#~/django/myapp/management/commands/acme.py
def foo():
pass
class Command(BaseCommand):
def handle(self, *args, **options):
foo()
#~/django/myapp/tests/test.py
from django.core.management import call_command
@mock.patch('myapp.management.commands.acme.foo')
def test_command_output(self,mock_foo):
call_command('acme')
assert not mock_foo.called