Julian Berman added the comment:

It's slightly less confusing -- "Where do I patch" is the question that will 
never go away, and the fact that you don't have the `sys` module imported is a 
small hint that you should be doing patch(mymodule.sys, "path") not 
patch("sys.path"). Also, the fact that patch is more common doesn't reflect the 
fact that most of those times, patch.object would have worked as well, but it's 
longer to type (or people aren't as aware of it), since most of the time you're 
patching things in a module you've imported already (at least this is true of 
me, and I've started using patch.object whenever it works and only falling back 
on patch).

Also, Twisted's TestCase (which already has a method to implement patch) is 
functionally equivalent to patch.object, not patch, in case you wanted a 
precedent.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11664>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to