Created
September 26, 2015 05:03
-
-
Save nhoad/5bae1f08b6f770b0af7d to your computer and use it in GitHub Desktop.
This file contains 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
from unittest import mock | |
class AttributeTrackMock(mock.Mock): | |
def __init__(self, *args, **kwargs): | |
super().__init__(*args, **kwargs) | |
self.attr_accesses = [] | |
def __getattr__(self, attr): | |
res = super().__getattr__(attr) | |
self.attr_accesses.append(res) | |
return res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment