def webtest_maybe_follow(response, **kw):
 remaining_redirects = 100
 while ((300 <= response.status_int < 400) and remaining_redirects):
  response = response.follow(**kw)
  remaining_redirects -= 1
 assert (remaining_redirects > 0), 'redirects chain looks infinite'
 return response

def webtest_maybe_follow ( response , ** kw ) : remaining_redirects = 100 while ( ( 300 <= response . status_int < 400 ) and remaining_redirects ) : response = response . follow ( ** kw ) remaining_redirects -= 1 assert ( remaining_redirects > 0 ) , 'redirects chain looks infinite' return response
follow all redirects .