1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-09 17:15:35 +00:00

Merge pull request #201 from agriffis/path-transformer-default

Default path_transformer=None. Fixes #199
This commit is contained in:
Aron Griffis
2015-08-28 07:55:13 -04:00
5 changed files with 35 additions and 5 deletions

View File

@@ -75,7 +75,7 @@ class CassetteContextDecorator(object):
lambda key, _: key in self._non_cassette_arguments,
self._args_getter()
)
if 'path_transformer' in other_kwargs:
if other_kwargs.get('path_transformer'):
transformer = other_kwargs['path_transformer']
cassette_kwargs['path'] = transformer(cassette_kwargs['path'])
self.__finish = self._patch_generator(self.cls.load(**cassette_kwargs))

View File

@@ -29,7 +29,7 @@ class VCR(object):
return path
return ensure
def __init__(self, path_transformer=lambda x: x, before_record_request=None,
def __init__(self, path_transformer=None, before_record_request=None,
custom_patches=(), filter_query_parameters=(), ignore_hosts=(),
record_mode="once", ignore_localhost=False, filter_headers=(),
before_record_response=None, filter_post_data_parameters=(),
@@ -114,7 +114,7 @@ class VCR(object):
matcher_names = kwargs.get('match_on', self.match_on)
path_transformer = kwargs.get(
'path_transformer',
self.path_transformer or self.ensure_suffix('.yaml')
self.path_transformer
)
func_path_generator = kwargs.get(
'func_path_generator',

View File

@@ -83,8 +83,9 @@ def partition_dict(predicate, dictionary):
def compose(*functions):
def composed(incoming):
res = incoming
for function in functions[::-1]:
res = function(res)
for function in reversed(functions):
if function:
res = function(res)
return res
return composed