$npx skillfedfor your agent

kgb

Utilities for spying on function calls in unit tests.

Worth itPyPI Software DevelopmentReleased Dec 20259.4M downloads / moMITPure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — kgb-7.3-py2.py3-none-any.whl
v7.3 · released 2025-12-11 · Python !=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7

Yes. kgb is a lightweight, actively maintained testing utility with no dependencies, permissive licensing, and a clean API for function call verification. It's well-suited for any Python test suite that needs spy functionality without the overhead of full mocking frameworks.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Low friction: pure Python wheel with no runtime dependencies.
  • Actively maintained with a recent release and active repository.

License · maintenance · safety

MIT (permissive) — MIT license is permissive; you can use kgb in commercial and proprietary projects with minimal restrictions.

last release 2025-12-11 (246 days) · last repo commit 2026-07-07 · 53 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 9,403,872 downloads/mo, #1,536 on PyPI

Verify before relying

pip install kgb

from kgb import SpyAgency

agency = SpyAgency()
agency.spy_on(obj.function)
obj.function()
print(obj.function.called)  # True
print(obj.function.last_call.args)
  • Whether kgb works with Python 2.7 as documented (support statement says 2.7 and 3.6–3.11, but classifiers list 3.12–3.13)
Same gist for agents: .md · .json

What it is and what it does

kgb is a spy library for Python unit tests that intercepts function calls without requiring you to write mock objects. When you spy on a function, kgb records every call—its arguments, return value, and any exceptions—and lets you query that history in your test assertions. You can configure a spy to call the original function, block it entirely, or reroute it to a fake function you provide.

The library integrates with unittest, pytest, nose, and nose2, and can be used as a mixin in test classes, a context manager for quick one-off spies, or through a SpyAgency object that manages multiple spies. It has no runtime dependencies and installs as a pure Python wheel, making it lightweight and easy to add to any test suite.

Use it for

  • Verify that a method was called with specific arguments without mocking the entire object
  • Count how many times a function is invoked during a test to ensure it's not called more than expected
  • Block a function call in tests (e.g., prevent side effects) while still recording that it was attempted
  • Reroute a function to a fake implementation to test error handling or alternative behavior
  • Track the sequence and details of multiple function calls across a test to verify interaction order

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

Worth it

Yes.

kgb is a lightweight, actively maintained testing utility with no dependencies, permissive licensing, and a clean API for function call verification. It's well-suited for any Python test suite that needs spy functionality without the overhead of full mocking frameworks.

Install

kgb on PyPI

Before you install

Low friction: pure Python wheel with no runtime dependencies. Actively maintained with a recent release and active repository.

License in practice

MIT license is permissive; you can use kgb in commercial and proprietary projects with minimal restrictions.

Quickstart

pip install kgb

from kgb import SpyAgency

agency = SpyAgency()
agency.spy_on(obj.function)
obj.function()
print(obj.function.called)  # True
print(obj.function.last_call.args)

Verify before relying

  • Whether kgb works with Python 2.7 as documented (support statement says 2.7 and 3.6–3.11, but classifiers list 3.12–3.13)

Package facts

LicenseMIT permissive
Python supportSupports the current Python release !=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7
Install frictionLow. Pure-Python wheel
Runtime dependenciesNone
MaintenanceActively maintained 246 days since the last release
Last repo commit
First released
Downloads9,403,872 / month, #1,536 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Development Status :: 5 - Production/StableEnvironment :: Other EnvironmentFramework :: PytestIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 2Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software DevelopmentTopic :: Software Development :: Libraries :: Python ModulesTopic :: Software Development :: Testing

Evidence: kgb-7.3-py2.py3-none-any.whl

Tags

Capabilities
function call spies for testingmock function calls and verifyintercept and record function callsunit test spy librarypytest spy on functionsunittest function call tracking
Topics
testingspiesunittest
PyPI keywords
pytestunit testsspies

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “function call spies for testing”

  • kgbkgb intercepts and records function calls in unit tests, letting you…
  • bfcl-evalEvaluates and benchmarks large language models' ability to invoke…
  • flexmockflexmock creates mock, stub, spy, and fake objects for testing Python…

Give your agent the search over MCP, or paste the wish link into any chat.

More Software Development packages

typing-extensions Worth it
PyPI · Software Development · released Jul 2026

Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.

PSF-2.0pure Python · 3.9+
1.9Bdownloads / mo
numpy Worth it
PyPI · Software Development · released Aug 2026

NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.

BSD-3-Clause AND 0BSD AND MIT AND Zlib AND CC0-1.0compiled wheel · 3.12+
1.1Bdownloads / mo
fastapi Worth it
PyPI · Software Development · released Jul 2026

FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.

MITpure Python · 3.10+
568.6Mdownloads / mo
annotated-doc With conditions
PyPI · Software Development · released Jul 2026

Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.

MITpure Python · 3.9+
456.2Mdownloads / mo
typer Worth it
PyPI · Software Development · released Aug 2026

Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.

Install it if you are building CLIs in Python.

MITpure Python · 3.10+
369.3Mdownloads / mo
distlib With conditions
PyPI · Software Development · released Jun 2026

Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.

permissive licensepure Python
323.3Mdownloads / mo

See also pytest-mock · snoop · pytest-logger · seeq-spy · flexmock · pyfakefs · pytest-subtests · pytest-faker · wrapt · nose2