mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-09 09:13:23 +00:00
Revert "Add global toggle to use_cassette."
This reverts commit 366e2b75bb.
Conflicts:
tests/unit/test_cassettes.py
This commit is contained in:
@@ -14,33 +14,15 @@ from .matchers import requests_match, uri, method
|
||||
from .errors import UnhandledHTTPRequestError
|
||||
|
||||
|
||||
class NullContextDecorator(object):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
def __enter__(self, *args):
|
||||
return self
|
||||
|
||||
def __exit__(self, *args):
|
||||
pass
|
||||
|
||||
def __call__(self, function):
|
||||
return function
|
||||
|
||||
|
||||
class use_cassette(object):
|
||||
|
||||
_enabled = True
|
||||
|
||||
def __init__(self, cls, *args, **kwargs):
|
||||
self.args = args
|
||||
self.kwargs = kwargs
|
||||
self.cls = cls
|
||||
|
||||
def __enter__(self):
|
||||
self._cassette = self.cls.load(*self.args, **self.kwargs) if self._enabled \
|
||||
else NullContextDecorator()
|
||||
self._cassette = self.cls.load(*self.args, **self.kwargs)
|
||||
return self._cassette.__enter__()
|
||||
|
||||
def __exit__(self, *args):
|
||||
|
||||
Reference in New Issue
Block a user