Skip to content

Instantly share code, notes, and snippets.

@nhoad
Created September 26, 2015 05:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nhoad/5bae1f08b6f770b0af7d to your computer and use it in GitHub Desktop.
Save nhoad/5bae1f08b6f770b0af7d to your computer and use it in GitHub Desktop.
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