Looking at this webpage: http://www.toptal.com/python/an-introduction-to-mocking-in-python -- The author talks about Mocking and Patching in Python and gives a pretty solid \"re
When applying a decorator, it is good to look at it like this
**Your Function**
Basically your function is required to interact with the wrappers in this order:
wrapper3
-> wrapper2
->wrapper1
@wrapper1
@wrapper2
@wrapper3
def your_func(wrapper1.input, wrapper2.input, wrapper3.input):
NOTE wrapper1.input isn't how you would actually reference its input
To answer the second part of your question, how mymodule.os
knows to refer to os. When Patching you are effectively intercepting calls to that specific name. When you call os
in mymodule
you are effectively calling mymodule.os
. When patching you must refer to the class that is being mocked by the way it is being called in the actual code, not from the test modules perspective