Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/AtaLuZiK/pyspider into At…
Browse files Browse the repository at this point in the history
…aLuZiK-master

add test for max_redirects
  • Loading branch information
binux committed Nov 21, 2015
2 parents ab288a0 + 8189985 commit 647766f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions pyspider/libs/base_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ def _crawl(self, url, **kwargs):
'fetch_type',
'use_gzip',
'validate_cert',
'max_redirects'
):
if key in kwargs:
fetch[key] = kwargs.pop(key)
Expand Down
9 changes: 9 additions & 0 deletions tests/test_fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,12 @@ def test_a170_validate_cert(self):
response = rebuild_response(result)

self.assertEqual(response.status_code, 200, result)

def test_a180_max_redirects(self):
request = copy.deepcopy(self.sample_task_http)
request['fetch']['max_redirects'] = 10
request['url'] = self.httpbin+'/redirect/10'
result = self.fetcher.sync_fetch(request)
response = rebuild_response(result)

self.assertEqual(response.status_code, 200, result)

0 comments on commit 647766f

Please sign in to comment.