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