Issue mocking with a decorated method call in Python 2.7

蹲街弑〆低调 提交于 2019-12-05 22:09:42

From mock 1.1.0 the framework start to check deeply methods signature. Take a look to the changelog at

Issue #17015: When it has a spec, a Mock object now inspects its signature when matching calls, so that arguments can be matched positionally or by name

Now if you change f2() signature to def f_2(arg, *args, **kwargs) it should work.

Maybe that is a new bug where the signature check cannot understand correctly that the call is correct (at least compatible). I think that you can file a bug and post here the ticket link.

As workaround you can remove the autospeccing from method_1 by add

m.method_1 = mock.Mock()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!