Closed GoogleCodeExporter closed 8 years ago
Patch works by changing what objects names point to. So patch('os.kill', thing)
says "change the 'kill' name in the os module to point to 'thing'". If you have
directly imported kill then you have created a new local name (in the module
you imported it) pointing to the original kill object.
There is *no way* in Python (no sane way anyway) to say - "find every name
pointing to os.kill and rebind them to point to something else". What you need
to do is patch the name kill *in the module where it is being used*.
I've tried to explain this in the "where to patch" section of the documentation:
http://www.voidspace.org.uk/python/mock/patch.html#where-to-patch
Original comment by fuzzyman
on 3 Nov 2011 at 4:14
Original issue reported on code.google.com by
otoomuel...@googlemail.com
on 3 Nov 2011 at 4:03