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:
@@ -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'''
|
||||
|
||||
Reference in New Issue
Block a user