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

Add Decorator Support

This commit is contained in:
Kevin McCarthy
2013-12-15 16:43:11 -10:00
parent 0d08157e5d
commit 144d25bc66
4 changed files with 30 additions and 3 deletions

View File

@@ -22,7 +22,7 @@ This should work with Python 2.6 and 2.7, and [pypy](http://pypy.org).
Currently I've only tested this with urllib2, urllib3, and requests. It's known to *NOT WORK* with urllib.
##How to use it
##Usage
```python
import vcr
import urllib2
@@ -40,6 +40,17 @@ pass, even if you are offline, or iana.org goes down for maintenance) and
accurate (the response will contain the same headers and body you get from a
real request).
You can also use VCR.py as a decorator. The same request above would look like this:
```
@vcr.use_cassette('fixtures/vcr_cassettes/synopsis.yaml'):
def test_iana():
response = urllib2.urlopen('http://www.iana.org/domains/reserved').read()
assert 'Example domains' in response
```
All of the parameters and configuration works the same for the decorator version.
## Configuration
If you don't like VCR's defaults, you can set options by instantiating a