From 7990c549d1b1ccc304431f95437f92ff17c29738 Mon Sep 17 00:00:00 2001 From: Bocai Cen Date: Thu, 1 Oct 2015 23:17:15 -0400 Subject: [PATCH] fix decoration when in _handle_function does not return the wrapped function return value --- tests/unit/test_vcr.py | 11 +++++++++++ vcr/cassette.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/unit/test_vcr.py b/tests/unit/test_vcr.py index 85df61a..1f4d49a 100644 --- a/tests/unit/test_vcr.py +++ b/tests/unit/test_vcr.py @@ -301,6 +301,17 @@ def test_additional_matchers(): function_additional() +def test_decoration_should_respect_function_return_value(): + vcr = VCR() + ret = 'a-return-value' + + @vcr.use_cassette + def function_with_return(): + return ret + + assert ret == function_with_return() + + class TestVCRClass(VCR().test_case()): def no_decoration(self): diff --git a/vcr/cassette.py b/vcr/cassette.py index 6dc6c40..db94224 100644 --- a/vcr/cassette.py +++ b/vcr/cassette.py @@ -127,7 +127,7 @@ class CassetteContextDecorator(object): def _handle_function(self, function, args, kwargs): with self as cassette: - self.__handle_function(cassette, function, args, kwargs) + return self.__handle_function(cassette, function, args, kwargs) @staticmethod def get_function_name(function):