diff --git a/tests/unit/test_vcr.py b/tests/unit/test_vcr.py index d6a88fc..d58d96c 100644 --- a/tests/unit/test_vcr.py +++ b/tests/unit/test_vcr.py @@ -147,6 +147,24 @@ def test_cassette_library_dir_with_decoration_and_no_explicit_path(): function_name() +def test_cassette_library_dir_with_decoration_and_explicit_path(): + library_dir = '/libary_dir' + vcr = VCR(inject_cassette=True, cassette_library_dir=library_dir) + @vcr.use_cassette(path='custom_name') + def function_name(cassette): + assert cassette._path == os.path.join(library_dir, 'custom_name') + function_name() + + +def test_cassette_library_dir_with_decoration_and_super_explicit_path(): + library_dir = '/libary_dir' + vcr = VCR(inject_cassette=True, cassette_library_dir=library_dir) + @vcr.use_cassette(path=os.path.join(library_dir, 'custom_name')) + def function_name(cassette): + assert cassette._path == os.path.join(library_dir, 'custom_name') + function_name() + + def test_cassette_library_dir_with_path_transformer(): library_dir = '/libary_dir' vcr = VCR(inject_cassette=True, cassette_library_dir=library_dir, diff --git a/vcr/config.py b/vcr/config.py index 6a5de5b..fb03136 100644 --- a/vcr/config.py +++ b/vcr/config.py @@ -120,6 +120,7 @@ class VCR(object): def add_cassette_library_dir(path): if not path.startswith(cassette_library_dir): return os.path.join(cassette_library_dir, path) + return path path_transformer = compose(add_cassette_library_dir, path_transformer) elif not func_path_generator: # If we don't have a library dir, use the functions