def __getattr__(self, attr): if attr in self._data: if isinstance(self._data[attr], dict): return DataDict(self._data[attr], attr, self) return self._data[attr] elif attr in self.collections_map[self.type]: return self._child_collection(attr) else: raise AttributeError(attr)
def setUp(self): self.obj = Mock() self.obj.data = {} self.data = {'favorite food': 'Tacos', 'favorite drink': 'Beer'} self.dict = DataDict(self.data, 'data', self.obj)