Hello
On 18 December 2010 14:51, Virgil Dupras <[email protected]> wrote:
> Hi there,
>
> Monkeypatching is great and all, but some type of patching is a little bit
> more complex to do, such as patching the system time and patching os.stat for
> specific filenames. I have my own "homebrewed" solution for this, but I was
> wondering if such solution had their place in the monkeypatch module of
> pytest itself. Does it? Or should a "pytest-monkeypatch++" package be created?
>
> The "homebrewed" code I'm talking about is at
> https://bitbucket.org/hsoft/hsutil/src/43014954c6a8/hsutil/testutil.py#cl-83
> ( patch_osstat() and patch_today() ).
Looking at the patch_osstat() it seems to me that it just fakes
os.stat() for one specific path but uses the original in place
otherwise. This sounds like it could be just a specialised object
used to patch with. I can imagine the monkeypatch plugin to provide a
funcarg which provides this functionality, e.g.:
def test_foo(monkeypatch, monkey_osstat):
monkeypatch.setattr(monkey_ossstat('/tmp/some_file'))
...
Though probably with better names ;-).
I'm not sure I understand the use case for patch_today() so won't
comment on that part.
Regards
Floris
--
Debian GNU/Linux -- The Power of Freedom
www.debian.org | www.gnu.org | www.kernel.org
_______________________________________________
py-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/py-dev