Created
July 11, 2013 05:39
-
-
Save toastdriven/5972796 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Trackable(object): | |
| def __init__(self, *args, **kwargs): | |
| self._calls = [] | |
| self._parent = None | |
| def __getattr__(self, name): | |
| self._calls.append({ | |
| 'method': '__getattribute__', | |
| 'args': [name], | |
| 'kwargs': {}, | |
| }) | |
| return self | |
| def __call__(self, *args, **kwargs): | |
| self._calls.append({ | |
| 'method': self.__dict__.get('__new_name__', 'Unnamed'), | |
| 'args': args, | |
| 'kwargs': kwargs, | |
| }) | |
| class FakeClient(Trackable): | |
| def __getattribute__(self, name): | |
| trackable = Trackable() | |
| trackable.parent = self | |
| trackable.__new_name__ = name | |
| return trackable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment