Skip to content

Instantly share code, notes, and snippets.

View leonardbinet's full-sized avatar
🐑

Léonard Binet leonardbinet

🐑
View GitHub Profile
@leonardbinet
leonardbinet / README.md
Last active August 9, 2020 22:24
Python spier decorator

Suppose you want to want to track all calls (args, kwargs and result) made to a given method while running a command, you can do it using the simple decorator defined in the spy.py module of this gist.

Usage

You can use it to spy either on a single instance or to all instances of given class.

The calls will be stored in a list that must be passed by instantiated beforehand and passed to the decorator.

Spy on single instance