我想修补作业模板标签,但这个问题不是Django特有的。
以下是我想要达到的目标:
@patch('the_caller_path.my_function', _my_mock)
class MyTests(...):
我得到的“明显”错误是:
AttributeError: <module 'the_caller_path' from '...'> does not have the attribute 'my_function'
问题是the_caller
动态调用my_function
。你知道吗
正如预期的那样,使用路径WARE声明函数没有任何效果:
@patch('the_real_path.my_function', _my_mock)
class MyTests(...):
my_function
未修补。你知道吗
如何对函数进行全局修补?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐