How to patch a module's internal functions with mock?

后端 未结 4 1261
情书的邮戳
情书的邮戳 2021-02-01 05:15

By \"internal function\", I mean a function that is called from within the same module it is defined in.

I am using the mock library, specifically the patch decorators,

4条回答
  •  忘掉有多难
    2021-02-01 05:40

    I'm pretty sure your problem is that you are importing 'mymodule' inside your test functions, and therefore the patch decorator has no chance of actually patching. Do the import at the top of the module, like any other import.

提交回复
热议问题