[TIP] "disable" in patch

Herman Sheremetyev herman at swebpage.com
Sun Dec 12 02:53:38 PST 2010

If I understand your use case properly then what you really want is a
set of integration tests. If you really want to use the same tests for
integration as your unittests the way you describe, then you can
already accomplish the same goal by replacing the stubbing/patching
function with a function that doesn't stub them out when you run in
integration mode.

So instead of:

@patch(blah, disable=HTTP_CALLS)
def test():

You would write:

patch_function = patch
def test():

And then just change the value of patch to lambda or some empty
function when you want to test against the real server. The amount of
code is basically the same on your end.



On Sun, Dec 12, 2010 at 11:23 AM, Alexandre Conrad
<alexandre.conrad at gmail.com> wrote:
> Hey there,
> I have created an issue on Google Code for a feature enhancement. Although I
> have learned about this mailing list *after* I created the issue and I wish
> I could have exposed my idea before.
> Nevertheless, I wanted to know how this idea would be accepted by the python
> mock community. The details are here:
> http://code.google.com/p/mock/issues/detail?id=60
> Thanks,
> --
> Alex | twitter.com/alexconrad
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python

More information about the testing-in-python mailing list