Graham Dumpleton, the developer behind wrapt, mod_wsgi and New Relic's Python agent, released Wrapture, a library that extends wrapt's monkeypatching into testing and tracing, according to Simon Willison's blog and the project's documentation.
Wrapture wraps any function or method so every call can be traced or have its return value overridden, working as an alternative to Python's built-in unittest.mock, Willison wrote. It also adds configuration based tracing that can be layered onto an existing project's code with OpenTelemetry, without modifying that code directly.
The library supports stubbing a method with a custom return value and transforming a result after calling the original method, according to the documentation.
Dumpleton said the project, only weeks old, was built with heavy AI assistance, but described the process as careful engineering that used AI as an implementation tool rather than unsupervised "vibe coding," Willison wrote.
Testing and tracing have used separate tooling for years: mocks for one, instrumentation for the other. A library built by the person behind wrapt and mod_wsgi, treating both as the same wrapping problem, is worth a look for any Python team maintaining separate mocking and tracing setups.