Coverage for vcr.config : 73%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
record_mode="once", filter_headers=(), ignore_localhost=False, custom_patches=(), filter_query_parameters=(), filter_post_data_parameters=(), before_record_request=None, before_record_response=None, ignore_hosts=(), match_on=('method', 'scheme', 'host', 'port', 'path', 'query'), before_record=None, inject_cassette=False): 'yaml': yamlserializer, 'json': jsonserializer, } 'method': matchers.method, 'uri': matchers.uri, 'url': matchers.uri, # matcher for backwards compatibility 'scheme': matchers.scheme, 'host': matchers.host, 'port': matchers.port, 'path': matchers.path, 'query': matchers.query, 'headers': matchers.headers, 'body': matchers.body, }
except KeyError: print("Serializer {0} doesn't exist or isn't registered".format( serializer_name )) raise KeyError
except KeyError: raise KeyError( "Matcher {0} doesn't exist or isn't registered".format(m) )
path, config = self.get_path_and_merged_config(path, **kwargs) return Cassette.use(path, **config) # This is made a function that evaluates every time a cassette # is made so that changes that are made to this VCR instance # that occur AFTER the `use_cassette` decorator is applied # still affect subsequent calls to the decorated function. path, **kwargs)
'cassette_library_dir', self.cassette_library_dir )
'serializer': self._get_serializer(serializer_name), 'match_on': self._get_matchers(matcher_names), 'record_mode': kwargs.get('record_mode', self.record_mode), 'before_record_request': self._build_before_record_request(kwargs), 'before_record_response': self._build_before_record_response( kwargs ), 'custom_patches': self._custom_patches + kwargs.get( 'custom_patches', () ), 'inject': kwargs.get('inject_cassette', self.inject_cassette) }
'before_record_response', self.before_record_response ) collections.Iterable): before_record_response = (before_record_response,) for function in before_record_response: filter_functions.append(function) if response is None: break response = function(response)
'filter_headers', self.filter_headers ) 'filter_query_parameters', self.filter_query_parameters ) 'filter_post_data_parameters', self.filter_post_data_parameters ) "before_record_request", options.get("before_record", self.before_record_request) ) 'ignore_hosts', self.ignore_hosts ) 'ignore_localhost', self.ignore_localhost ) headers_to_remove=filter_headers)) filter_functions.append(functools.partial(filters.remove_query_parameters, query_parameters_to_remove=filter_query_parameters)) filter_functions.append(functools.partial(filters.remove_post_data_parameters, post_data_parameters_to_remove=filter_post_data_parameters))
hosts_to_ignore.extend(('localhost', '0.0.0.0', '127.0.0.1'))
hosts_to_ignore = set(hosts_to_ignore) filter_functions.append(self._build_ignore_hosts(hosts_to_ignore))
if not isinstance(before_record_request, collections.Iterable): before_record_request = (before_record_request,) for function in before_record_request: filter_functions.append(function) break
def _build_ignore_hosts(hosts_to_ignore): def filter_ignored_hosts(request): if hasattr(request, 'host') and request.host in hosts_to_ignore: return return request return filter_ignored_hosts
self.serializers[name] = serializer
self.matchers[name] = matcher |