1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-09 01:03:24 +00:00

Fix use_cassette decorator in python 2 by using wrapt.decorator. Add wrapt as dependency.

This commit is contained in:
Ivan Malison
2014-09-22 16:40:09 -07:00
parent 3dea853482
commit b046ee4bb1
3 changed files with 28 additions and 3 deletions

View File

@@ -2,6 +2,7 @@
import logging
import contextlib2
import wrapt
try:
from collections import Counter
except ImportError:
@@ -19,7 +20,7 @@ from .errors import UnhandledHTTPRequestError
log = logging.getLogger(__name__)
class CassetteContextDecorator(contextlib2.ContextDecorator):
class CassetteContextDecorator(object):
"""Context manager/decorator that handles installing the cassette and
removing cassettes.
@@ -58,6 +59,11 @@ class CassetteContextDecorator(contextlib2.ContextDecorator):
next(self.__finish, None)
self.__finish = None
@wrapt.decorator
def __call__(self, function, instance, args, kwargs):
with self:
return function(*args, **kwargs)
class Cassette(object):
'''A container for recorded requests and responses'''