From 944c9625269f26f73fe990b24d8133539cc5d99a Mon Sep 17 00:00:00 2001 From: Rob Cutmore Date: Wed, 14 Oct 2015 19:13:51 -0400 Subject: [PATCH] Fix default retry backoff factor 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] --- robobrowser/browser.py | 2 +- tests/test_browser.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/robobrowser/browser.py b/robobrowser/browser.py index 32e9338..96a2324 100644 --- a/robobrowser/browser.py +++ b/robobrowser/browser.py @@ -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() diff --git a/tests/test_browser.py b/tests/test_browser.py index 45731ca..b17a305 100644 --- a/tests/test_browser.py +++ b/tests/test_browser.py @@ -343,3 +343,12 @@ 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): + + def test_default_backoff_factor_not_none(self): + session = RoboBrowser(tries=3).session + for protocol in session.adapters: + factor = session.adapters[protocol].max_retries.backoff_factor + assert_true(factor is not None)