# kgb — Function spies for Python
   
**GitHub:** https://github.com/beanbaginc/kgb
**PyPI:** https://pypi.org/project/kgb
**Status:** Under active development / released / used in production
kgb allows [[Registries]] developers to spy on functions, intercept and track calls, and fake functionality. You can see how many times a function was called, what arguments were passed, what was returned, what exceptions were raised.
This is built for unit tests, though it can be used for anything.
it's better than mocks, and it leaves no trace.
It works by modifying the bytecode of a function, rather than replacing the function the way a mock does. This leads to fewer side-effects and can be used in more places than mocks can.
It's a unit test developer's secret weapon.