[TIP] mock and patch

Andrea Crotti andrea.crotti.0 at gmail.com
Thu Mar 22 03:37:57 PDT 2012

I was reading the doc at

and so I tried this simple example, which I though would fail, because
from the doc I should instead patch 'module.getcwd' instead of

from os import getcwd

def mycwd(_):


<MagicMock name='getcwd()' id='32916368'>

But the patch actually works perfectly anyway, so am I misunderstanding
the doc or maybe it's not updated to the last (smarter) behaviour of the
mock library?

More information about the testing-in-python mailing list