我在函数中有一个import语句,我想用patch修改import语句,但是不能。
class A():
"""mock object"""
@staticmethod
def run():
print('ran')
@patch('something')
def test_run(self, something):
something = A()
# my function has this statement
from something import run
run(....)
得到
E TypeError: Need a valid target to patch. You supplied: 'something'