Wrapture, developed by Graham Dumpleton, extends the monkeypatching concepts from wrapt to facilitate testing and tracing simultaneously. It allows wrapping any function or method to trace access or override return values, serving as an alternative to unittest.mock.
The library includes support for OpenTelemetry and offers a configuration-based approach to add tracing to existing Python code. This enables attaching observation to code without modifying its core, which is useful for monitoring and debugging.
Wrapture is a new project, just a few weeks old, and was developed with AI assistance under careful engineering. It supports testing patterns such as stubbing and transforming return values, demonstrated through example test cases.
This tool is relevant for engineers managing models and agents, as it simplifies adding observability and testing capabilities to complex Python systems.
Source: https://simonwillison.net/2026/Aug/31/introducing-wrapture/