mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-09 01:03:24 +00:00
New Feature: Ignore Some Requests
Add 2 new options, ignore_localhost and ignore_hosts, which can ignore requests so they aren't recorded in a cassette. Closes #74
This commit is contained in:
@@ -20,6 +20,8 @@ class VCR(object):
|
||||
'path',
|
||||
'query',
|
||||
],
|
||||
ignore_hosts=[],
|
||||
ignore_localhost=False,
|
||||
):
|
||||
self.serializer = serializer
|
||||
self.match_on = match_on
|
||||
@@ -44,6 +46,8 @@ class VCR(object):
|
||||
self.filter_headers = filter_headers
|
||||
self.filter_query_parameters = filter_query_parameters
|
||||
self.before_record = before_record
|
||||
self.ignore_hosts = ignore_hosts
|
||||
self.ignore_localhost = ignore_localhost
|
||||
|
||||
def _get_serializer(self, serializer_name):
|
||||
try:
|
||||
@@ -82,9 +86,21 @@ class VCR(object):
|
||||
"serializer": self._get_serializer(serializer_name),
|
||||
"match_on": self._get_matchers(matcher_names),
|
||||
"record_mode": kwargs.get('record_mode', self.record_mode),
|
||||
"filter_headers": kwargs.get('filter_headers', self.filter_headers),
|
||||
"filter_query_parameters": kwargs.get('filter_query_parameters', self.filter_query_parameters),
|
||||
"before_record": kwargs.get("before_record", self.before_record),
|
||||
"filter_headers": kwargs.get(
|
||||
'filter_headers', self.filter_headers
|
||||
),
|
||||
"filter_query_parameters": kwargs.get(
|
||||
'filter_query_parameters', self.filter_query_parameters
|
||||
),
|
||||
"before_record": kwargs.get(
|
||||
"before_record", self.before_record
|
||||
),
|
||||
"ignore_hosts": kwargs.get(
|
||||
'ignore_hosts', self.ignore_hosts
|
||||
),
|
||||
"ignore_localhost": kwargs.get(
|
||||
'ignore_localhost', self.ignore_localhost
|
||||
),
|
||||
}
|
||||
|
||||
return Cassette.load(path, **merged_config)
|
||||
|
||||
Reference in New Issue
Block a user