Permalink
Browse files

Merge remote-tracking branch 'origin/develop' into develop

  • Loading branch information...
2 parents ccf5504 + 1e61cf5 commit f1ffe19506654e735b684f0a33171967ae9bf0a1 @kennethreitz kennethreitz committed Oct 2, 2012
Showing with 7 additions and 3 deletions.
  1. +3 −3 requests/models.py
  2. +4 −0 tests/test_requests.py
View
@@ -462,10 +462,10 @@ def path_url(self):
def register_hook(self, event, hook):
"""Properly register a hook."""
- if isinstance(hook, (list, tuple, set)):
- self.hooks[event].extend(hook)
- else:
+ if callable(hook):
self.hooks[event].append(hook)
+ elif hasattr(hook, '__iter__'):
+ self.hooks[event].extend(h for h in hook if callable(h))
def deregister_hook(self, event, hook):
"""Deregister a previously registered hook.
View
@@ -778,6 +778,10 @@ def assert_hooks_are_callable(hooks):
r = requests.models.Request(hooks={'args': hooks})
assert_hooks_are_callable(r.hooks)
+ hooks.append('string that should not be registered')
+ r = requests.models.Request(hooks={'args': hooks})
+ assert_hooks_are_callable(r.hooks)
+
def test_session_persistent_cookies(self):
s = requests.session()

0 comments on commit f1ffe19

Please sign in to comment.