Introducing wrapture
Read OriginalThis article introduces wrapture, a new Python library by Graham Dumpleton (creator of wrapt and mod_wsgi) that extends monkeypatching to testing and tracing. It allows wrapping any function or method for tracing or overriding return values, serving as an alternative to unittest.mock and a tool for observing code you don't control. Wrapture includes OpenTelemetry support and a configuration-based mechanism for adding tracing to existing projects. The article also discusses its origin as an AI-assisted project and provides examples of its testing patterns, such as stubbing and modifying return values.
Comments
No comments yet
Be the first to share your thoughts!
Browser Extension
Get instant access to AllDevBlogs from your browser
Top of the Week
No top articles yet