beanbaginc / kgb

Python function spy support for unit tests
MIT License
48 stars 5 forks source link

Added exposure for spy via `with` #1

Closed twolfson closed 9 years ago

twolfson commented 9 years ago

I am using kgb with requests and noticed that when using the with context, the override would not be accessible. For example:

with spy_on(requests.post):
  requests.post # Original `requests.post`, not spy

To remedy this, I have exposed the spy via yield:

with spy_on(requests.post) as spy:
  spy # Our spy for `requests.post`

In this PR:

chipx86 commented 9 years ago

Hey, thanks for the contribution! Would you mind posting this on https://reviews.reviewboard.org/? We perform all code review through there rather than through pull requests.

Thanks again!

chipx86 commented 9 years ago

Actually, nevermind. This code looks great and I don't want you to jump through more hoops. :)

twolfson commented 9 years ago

Wow, that was fast! Thanks!

twolfson commented 9 years ago

It looks like a release hasn't occurred since this PR has been landed. Could we get one?

chipx86 commented 9 years ago

Sorry, it dropped off my radar.

0.5.2 is now out.

twolfson commented 9 years ago

Awesome, thanks =)