mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-11 18:06:10 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad6f635ac2 | ||
|
|
142b840eee | ||
|
|
32c687522d | ||
|
|
5fc33c7e70 | ||
|
|
0f81f023c8 |
@@ -7,7 +7,8 @@ This is a Python version of [Ruby's VCR library](https://github.com/vcr/vcr).
|
|||||||
[](http://travis-ci.org/kevin1024/vcrpy)
|
[](http://travis-ci.org/kevin1024/vcrpy)
|
||||||
[](https://waffle.io/kevin1024/vcrpy)
|
[](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
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -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"
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user