Posts on the topic of wrapture, a Python package for monkey patching, testing and tracing built on top of wrapt, are as follows.
The starting point, on what wrapture is, why I built it, and how it was written:
This batch of posts covers using wrapture in unit tests, where the difference from unittest.mock is that the real code still runs and everything that flows through it is recorded:
- Unit testing with wrapture.
- Recording calls with wrapture.
- Phased behaviour in wrapture.
- Beyond callables in wrapture.
This batch of posts covers the tracing side, where the same bindings used in tests observe a running application instead, from a live call tree in a terminal through to spans in an OpenTelemetry backend:
- Live tracing with wrapture.
- Zero-code tracing with wrapture.
- Tracing Flask with wrapture.
- Finding slow code with wrapture.
- OpenTelemetry export in wrapture.
The documentation is the reference for everything the posts skip over, and the older posts collected under decorators and monkey patching cover wrapt, the library wrapture is built on.