Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Show HN: Altered States, Python monkey-patching for Humans (plexical.com)
5 points by JacobOscarson on March 6, 2012 | hide | past | favorite | 1 comment


We use the fudge module, and I have a small context manager that lets me do this:

    with autopatch(foo, bar, baz):
       foo.patch.method = something
       # first test here
       foo.patch.method = something_else
I've found that my tests usually require setting up a complex context, and then slightly varying the bit of context, so it's assuming Foo, Bar, Baz and X=1 we expect this, but if X=2 we expect that. YMMV.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: