Closed nikolalosic closed 4 years ago
Thanks for the patch! I also noticed this, and had it pending in my tree as part of some other work. It's a slightly difference approach (calling self.spies.clear()
), but I'll pull it out and give you credit as the author.
For future review requests, we perform all code reviews on our Review Board server, rather than using pull requests.
I always like to hear from kgb users. What are you using it for? We're always happy to link to projects in our README.
Made some tweaks and landed this. Thanks!
HI @chipx86, I'll use Review Board next time!
It's a private company project so can't tell you a lot about it. But anyway, kgb
is awesome and it really helped me build integration tests. I also plan to use it in future projects.
Thanks for the credit even if you have already fixed this!
Totally understandable, but I'm glad to hear you're enjoying it! It's still a pretty under-the-radar library. We need to get the word out.
I'll have KGB 6 out probably in the next week, maybe two. Highlights are going to be:
A @spy_for
decorator to simplify the pattern of defining a function and passing it to spy_on(..., call_fake=...)
. For example:
@self.spy_for(some_func)
def _my_fake_some_func(*args, **kwargs):
...
Some adapters you can pass to call_fake=
that let you define lists of arguments that map to call_original=
or call_fake=
settings. One lets you pass a list that are expected to be encountered in sequence (asserting automatically if any unexpected parameters comes up), and another lets you define all possible ones you expect without caring about order.
Both should be helpful for cases where you're working with a function (say, urlopen()
calls) that are going to be called multiple times but should produce different results.
If you have thoughts on things KGB might be missing for your workflows, let me know!
unspy_all
was not working correctly as it set spies to empty list but should be empty set.SpyAgency
wasn't usable after callingunspy_all
since it usesset
methods likeadd
.