[pytest-dev] monkeypatch.setattr versus replace

Antonio Cuni anto.cuni at gmail.com
Tue Sep 17 10:32:18 CEST 2013


Hi,

On 13/09/13 12:33, holger krekel wrote:
>      monkeypatch.setattr("os.path.abspath", lambda x: "/abc")

speaking about possible APIs, what about the following?

monkeypatch("os.path.abspath = foo")

I find it much more readable than the two or three argument versions, and it's 
in a way similar to what we have for py.test.raises("...").
The drawback is that the implementation is probably a bit trickier than what 
it is now.

ciao,
Anto


More information about the Pytest-dev mailing list