On 17/09/13 12:13, holger krekel wrote:
Not sure it would even be that useful TBH and would indeed be trickier
to implement, i guess. Maybe it's better to rather think about
higher level helpers than argue much about the setattr() convenience.
I think that designing a good API is not only about convenience, but it has a
high impact on how easy it is to learn to use the tool.
I just though of another variation on the theme:
monkeypatch(os.path).abspath = foobar # OR
monkey(os.path).abspath = foobar
I think this is the easiest to remember, to understand and it's also probably
very easy to implement.
Apart from the proposed setattr shortcut, i am also thinking of
direct mock (the lib from Michael Foord) support:
mock = monkeypatch.setmock("os.path.abspath")
not sure it's a good idea. I don't think it is much simpler than this:
mock = monekypatch.setattr("os.path.abspath", Mock())
apart that in the latter case you must import Mock explicitly, which is a good
thing IMHO.
_______________________________________________
Pytest-dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pytest-dev