Hi Virgil, not sure everyone is aware here (or in general) of the "monkeypatch" funcarg injection, so i first point to an older blog post of mine about it:
http://tetamap.wordpress.com/2009/03/03/monkeypatching-in-unit-tests-done-right/ it helps a lot if you quickly and safely want to patch global module/class attrs, dictionaries, environment variables etc. inside a test. On Wed, Feb 16, 2011 at 10:41 +0100, Virgil Dupras wrote: > Hi there, > > A few weeks ago I talked about the possibility of adding helpers to the > monkeypatch module. Today, I'm publishing a new plugin which I called > "monkeyplus" to test the water with these new helpers (patch_osstat, > patch_today). > > Repository is at https://bitbucket.org/hsoft/pytest-monkeyplus I like it from reading your docs, https://bitbucket.org/hsoft/pytest-monkeyplus/src Would simplify some of my tests. Maybe others have more suggestions of what could be useful to have monkeypatch support for? we have this currently: monkeypatch.setattr(obj, name, value, raising=True) monkeypatch.delattr(obj, name, raising=True) monkeypatch.setitem(mapping, name, value) monkeypatch.delitem(obj, name, raising=True) monkeypatch.setenv(name, value, prepend=False) monkeypatch.delenv(name, value, raising=True) monkeypatch.syspath_prepend(path) and with Virgils monkeyplus: monkeyplus.patch_osstat('foo/bar', st_mtime=42) monkeyplus.patch_today(year, month, day) from my side, for consistency the names should eventually be monkeypatch.osstat(path, **attrs) monkeypatch.today(year, month, day) If more people like such additions i'd be happy to incorporate a patch for the next release. best, holger > Virgil Dupras > _______________________________________________ > py-dev mailing list > py-dev@codespeak.net > http://codespeak.net/mailman/listinfo/py-dev > -- _______________________________________________ py-dev mailing list py-dev@codespeak.net http://codespeak.net/mailman/listinfo/py-dev