patrys / httmock

A mocking library for requests
Other
468 stars 57 forks source link

Allow real requests if return value from intercept is not a Response object #11

Closed larryweya closed 11 years ago

larryweya commented 11 years ago

Seems like the _real_session_send will never be reached since intercept always returns a valid Response object. Our use-case is that we want to be able to run the same test against the actual target server in which case we just modify the net-loc.

patrys commented 11 years ago

What I don't like is that currently whatever res is, it will be lost. Could you make instead say something like:

elif res is None:
    return None
else:
    raise TypeError(…)

This should make debugging much easier if your mock returns a type that we don't know how to handle.

larryweya commented 11 years ago

@patrys makes sense, I've updated the pull request to reflect.