def url_test(url, location=None, status_code=requests.codes.moved_permanently, req_headers=None, req_kwargs=None, resp_headers=None, query=None, follow_redirects=False, final_status_code=requests.codes.ok):
 test_data = {'url': url, 'location': location, 'status_code': status_code, 'req_headers': req_headers, 'req_kwargs': req_kwargs, 'resp_headers': resp_headers, 'query': query, 'follow_redirects': follow_redirects, 'final_status_code': final_status_code}
 expanded_urls = list(braceexpand(url))
 num_urls = len(expanded_urls)
 if (num_urls == 1):
  return test_data
 try:
  location_pattern = location.pattern
  test_data['location'] = location_pattern
 except AttributeError:
  location_pattern = None
 new_urls = []
 if location:
  expanded_locations = list(braceexpand(test_data['location']))
  num_locations = len(expanded_locations)
 for (i, url) in enumerate(expanded_urls):
  data = test_data.copy()
  data['url'] = url
  if (location and (num_urls == num_locations)):
   if (location_pattern is not None):
    data['location'] = re.compile(expanded_locations[i])
   else:
    data['location'] = expanded_locations[i]
  new_urls.append(data)
 return new_urls

def url_test ( url , location = None , status_code = requests . codes . moved_permanently , req_headers = None , req_kwargs = None , resp_headers = None , query = None , follow_redirects = False , final_status_code = requests . codes . ok ) : test_data = { 'url' : url , 'location' : location , 'status_code' : status_code , 'req_headers' : req_headers , 'req_kwargs' : req_kwargs , 'resp_headers' : resp_headers , 'query' : query , 'follow_redirects' : follow_redirects , 'final_status_code' : final_status_code } expanded_urls = list ( braceexpand ( url ) ) num_urls = len ( expanded_urls ) if ( num_urls == 1 ) : return test_data try : location_pattern = location . pattern test_data [ 'location' ] = location_pattern except AttributeError : location_pattern = None new_urls = [ ] if location : expanded_locations = list ( braceexpand ( test_data [ 'location' ] ) ) num_locations = len ( expanded_locations ) for ( i , url ) in enumerate ( expanded_urls ) : data = test_data . copy ( ) data [ 'url' ] = url if ( location and ( num_urls == num_locations ) ) : if ( location_pattern is not None ) : data [ 'location' ] = re . compile ( expanded_locations [ i ] ) else : data [ 'location' ] = expanded_locations [ i ] new_urls . append ( data ) return new_urls
function for producing a config dict for the redirect test .