Как я могу высмеять foo, чтобы он НЕ вызывался?
Вот моя последняя попытка:
#~/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
Подробнее здесь: https://stackoverflow.com/questions/792 ... om-command
Как высмеять функцию в пользовательской команде Django? ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Есть ли способ глобально высмеять класс, инициализированный вне функции?
Anonymous » » в форуме Python - 0 Ответы
- 19 Просмотры
-
Последнее сообщение Anonymous
-