1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-11 18:06:10 +00:00

Compare commits

...

5 Commits

Author SHA1 Message Date
Ivan Malison
ad6f635ac2 Version 1.5.2. 2015-05-15 16:54:40 -07:00
Ivan 'Goat' Malison
142b840eee Merge pull request #155 from gazpachoking/explicit_paths
Crash when cassette path contains cassette_library_dir
2015-05-15 16:51:03 -07:00
Chase Sterling
32c687522d Fix bug when specifying cassette path containing cassette_library_dir 2015-05-15 19:07:18 -04:00
Chase Sterling
5fc33c7e70 Add tests for explicitly specifying a path when library dir is defined 2015-05-15 19:06:05 -04:00
Ivan Malison
0f81f023c8 Fix readme, version 1.5.1 2015-05-14 14:46:14 -07:00
4 changed files with 24 additions and 2 deletions

View File

@@ -7,7 +7,8 @@ This is a Python version of [Ruby's VCR library](https://github.com/vcr/vcr).
[![Build Status](https://secure.travis-ci.org/kevin1024/vcrpy.png?branch=master)](http://travis-ci.org/kevin1024/vcrpy) [![Build Status](https://secure.travis-ci.org/kevin1024/vcrpy.png?branch=master)](http://travis-ci.org/kevin1024/vcrpy)
[![Stories in Ready](https://badge.waffle.io/kevin1024/vcrpy.png?label=ready&title=Ready)](https://waffle.io/kevin1024/vcrpy) [![Stories in Ready](https://badge.waffle.io/kevin1024/vcrpy.png?label=ready&title=Ready)](https://waffle.io/kevin1024/vcrpy)
## What it does VCR.py simplifies and speeds up tests that make HTTP ## What it does
VCR.py simplifies and speeds up tests that make HTTP
requests. The first time you run code that is inside a VCR.py context requests. The first time you run code that is inside a VCR.py context
manager or decorated function, VCR.py records all HTTP interactions manager or decorated function, VCR.py records all HTTP interactions
that take place through the libraries it supports and serializes and that take place through the libraries it supports and serializes and
@@ -542,6 +543,8 @@ API in version 1.0.x
## Changelog ## Changelog
* 1.5.2 Fix crash when cassette path contains cassette library
directory (thanks @gazpachoking).
* 1.5.0 Automatic cassette naming and 'application/json' post data * 1.5.0 Automatic cassette naming and 'application/json' post data
filtering (thanks @marco-santamaria). filtering (thanks @marco-santamaria).
* 1.4.2 Fix a bug caused by requests 2.7 and chunked transfer encoding * 1.4.2 Fix a bug caused by requests 2.7 and chunked transfer encoding

View File

@@ -20,7 +20,7 @@ class PyTest(TestCommand):
setup( setup(
name='vcrpy', name='vcrpy',
version='1.5.0', version='1.5.2',
description=( description=(
"Automatically mock your HTTP interactions to simplify and " "Automatically mock your HTTP interactions to simplify and "
"speed up testing" "speed up testing"

View File

@@ -147,6 +147,24 @@ def test_cassette_library_dir_with_decoration_and_no_explicit_path():
function_name() 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(): def test_cassette_library_dir_with_path_transformer():
library_dir = '/libary_dir' library_dir = '/libary_dir'
vcr = VCR(inject_cassette=True, cassette_library_dir=library_dir, vcr = VCR(inject_cassette=True, cassette_library_dir=library_dir,

View File

@@ -120,6 +120,7 @@ class VCR(object):
def add_cassette_library_dir(path): def add_cassette_library_dir(path):
if not path.startswith(cassette_library_dir): if not path.startswith(cassette_library_dir):
return os.path.join(cassette_library_dir, path) return os.path.join(cassette_library_dir, path)
return path
path_transformer = compose(add_cassette_library_dir, path_transformer) path_transformer = compose(add_cassette_library_dir, path_transformer)
elif not func_path_generator: elif not func_path_generator:
# If we don't have a library dir, use the functions # If we don't have a library dir, use the functions