Skip to content

Commit

Permalink
Fix default retry backoff factor
Browse files Browse the repository at this point in the history
Updated RoboBrowser class to default to a retry multiplier of 0
instead of None. Previously when set to None a TypeError would be
raised in the get_backoff_time method of urllib3's Retry class.

[Resolves #51]
  • Loading branch information
rcutmore committed Oct 14, 2015
1 parent 4284c11 commit dc7e97b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion robobrowser/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class RoboBrowser(object):
def __init__(self, session=None, parser=None, user_agent=None,
history=True, timeout=None, allow_redirects=True, cache=False,
cache_patterns=None, max_age=None, max_count=None, tries=None,
multiplier=None):
multiplier=0):

self.session = session or requests.Session()

Expand Down
10 changes: 10 additions & 0 deletions tests/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,3 +343,13 @@ def test_call_allow_redirects(self, mock_request):
assert_true(mock_request.called)
kwargs = mock_request.mock_calls[0][2]
assert_true(kwargs.get('allow_redirects') is False)


class TestRetry(unittest.TestCase):

@mock.patch('requests.Session.request')
def test_default_backoff_factor_not_none(self, mock_request):
session = RoboBrowser(tries=3).session
for protocol in session.adapters:
factor = session.adapters[protocol].max_retries.backoff_factor
assert_true(factor is not None)

0 comments on commit dc7e97b

Please sign in to comment.