nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: kevin1024/vcrpy
Pull request #811 (2024-01-23 15:07:40)

return values from generator decorator
I broke this in my previous PR sorry!

Needs a test


Patch:
diff --git a/docs/changelog.rst b/docs/changelog.rst
index 969dd11..52f6980 100644
--- a/docs/changelog.rst
+++ b/docs/changelog.rst
@@ -7,14 +7,6 @@ For a full list of triaged issues, bugs and PRs and what release they are target
 
 All help in providing PRs to close out bug issues is appreciated. Even if that is providing a repo that fully replicates issues. We have very generous contributors that have added these to bug issues which meant another contributor picked up the bug and closed it out.
 
--  6.0.0
-    - BREAKING: Fix issue with httpx support (thanks @parkerhancock) in #784. NOTE: You may have to recreate some of your cassettes produced in previous releases due to the binary format being saved incorrectly in previous releases
-    - BREAKING: Drop support for `boto` (vcrpy still supports boto3, but is dropping the deprecated `boto` support in this release. (thanks @jairhenrique)
-    - Fix compatibility issue with Python 3.12 (thanks @hartwork)
-    - Drop simplejson (fixes some compatibility issues) (thanks @jairhenrique)
-    - Run CI on Python 3.12 and PyPy 3.9-3.10 (thanks @mgorny)
-    - Various linting and docs improvements (thanks @jairhenrique)
-    - Tornado fixes (thanks @graingert)
 -  5.1.0
     - Use ruff for linting (instead of current flake8/isort/pyflakes) - thanks @jairhenrique
     - Enable rule B (flake8-bugbear) on ruff - thanks @jairhenrique
diff --git a/vcr/__init__.py b/vcr/__init__.py
index 89572bf..ad8cdc1 100644
--- a/vcr/__init__.py
+++ b/vcr/__init__.py
@@ -4,7 +4,7 @@ from logging import NullHandler
 from .config import VCR
 from .record_mode import RecordMode as mode  # noqa: F401
 
-__version__ = "6.0.0"
+__version__ = "5.1.0"
 
 logging.getLogger(__name__).addHandler(NullHandler())
 
diff --git a/vcr/cassette.py b/vcr/cassette.py
index fad0d25..5a189e3 100644
--- a/vcr/cassette.py
+++ b/vcr/cassette.py
@@ -125,7 +125,7 @@ class CassetteContextDecorator:
         duration of the generator.
         """
         with self as cassette:
-            yield from fn(cassette)
+            return (yield from fn(cassette))
 
     def _handle_function(self, fn):
         with self as cassette:


Test patch:
diff --git a/tests/unit/test_vcr.py b/tests/unit/test_vcr.py
index e285eb6..9e4d4bf 100644
--- a/tests/unit/test_vcr.py
+++ b/tests/unit/test_vcr.py
@@ -372,3 +372,19 @@ def test_path_class_as_cassette():
     )
     with use_cassette(path):
         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