Skip to content

Commit

Permalink
Restoring original __getattr__ behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
hugobast committed Mar 12, 2014
1 parent 6307821 commit 422ee29
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion delegator/delegator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ def _missing(*args, **kwargs):
else:
_missing = getattr(target, name)

return _missing
return _missing

raise AttributeError("'{0}' object has no attribute '{1}'".format(
self.__getobj__().__class__.__name__, name
))

def __setobj__(self, obj):
raise NotImplementedError("need to define `__setobj__'")
Expand Down
7 changes: 7 additions & 0 deletions test/tests_delegator.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,10 @@ def test_can_exec_callables_on_delegated_model(self):

def test_can_exec_callables_on_itself(self):
self.assertEqual(self.model_proxy.define(), "First Name, is a Person.")

def test_raises_no_method_found_error_as_expected(self):
with self.assertRaisesRegexp(
AttributeError,
r"'FrameworkObject' object has no attribute 'this_does_not_exists'"
):
self.model_proxy.this_does_not_exists()

0 comments on commit 422ee29

Please sign in to comment.