2
我需要一些模拟帮助。如何在类中的方法中模拟外部函数
我在mymodule.py下面的代码:
from someModule import external_function
class Class1(SomeBaseClass):
def method1(self, arg1, arg2):
external_function(param)
现在我有测试代码:
import mock
from django.test import TestCase
from mymodule import class1
class Class1Test(TestCase)
def test_method1:
'''how can I mock external_function here?'''
谢谢。不知何故,我嘲笑错误的东西。你把我弄直了。 – user2916464