Introducing wrapture
Introducing wrapture New from Graham Dumpleton (of wrapt , mod_wsgi, and New Relic's Python agent fame), who describes Wrapture as taking the monkeypatching ideas from wrapt and extending them to apply to testing and tracing at the same time. Wrapture ( full documentation here ) makes it easy to wrap any function or method such that all access can be traced, or can be overridden to return a…
Introducing Wrapture - a new tool from Graham Dumpleton, known for wrapt, mod_wsgi, and New Relic's Python agent. Wrapture combines the concepts of monkeypatching from wrapt with testing and tracing capabilities. This tool makes it simple to wrap any function or method, enabling tracing or allowing for the override of values. Wrapture serves as an alternative to unittest.mock and offers a means to implement tracing in existing projects without disturbing the program being observed.
The project, still in its early stages, boasts an impressive configuration-based mechanism for incorporating tracing into any Python project. Although it's Graham's first large-scale, AI-driven project, he assures readers that the AI was merely a tool to aid in the design, not the source of it. In his follow-up post, Unit testing with wrapture, Graham demonstrates the testing patterns supported by this new library, including a test that calls and modifies the return value from the original method.
Written by urgent.news from Simon Willison's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.