mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-09 01:03:24 +00:00
Merge pull request #811 from kevin1024/graingert-patch-1
return values from generator decorator
This commit is contained in:
@@ -372,3 +372,19 @@ def test_path_class_as_cassette():
|
|||||||
)
|
)
|
||||||
with use_cassette(path):
|
with use_cassette(path):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def test_use_cassette_generator_return():
|
||||||
|
ret_val = object()
|
||||||
|
|
||||||
|
vcr = VCR()
|
||||||
|
|
||||||
|
@vcr.use_cassette("test")
|
||||||
|
def gen():
|
||||||
|
return ret_val
|
||||||
|
yield
|
||||||
|
|
||||||
|
with pytest.raises(StopIteration) as exc_info:
|
||||||
|
next(gen())
|
||||||
|
|
||||||
|
assert exc_info.value.value is ret_val
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ class CassetteContextDecorator:
|
|||||||
duration of the generator.
|
duration of the generator.
|
||||||
"""
|
"""
|
||||||
with self as cassette:
|
with self as cassette:
|
||||||
yield from fn(cassette)
|
return (yield from fn(cassette))
|
||||||
|
|
||||||
def _handle_function(self, fn):
|
def _handle_function(self, fn):
|
||||||
with self as cassette:
|
with self as cassette:
|
||||||
|
|||||||
Reference in New Issue
Block a user