Skip to content

Timed decorator doesn't return wrapped function result #602

Merged
merged 1 commit into from Jan 18, 2013

2 participants

@dasickis

The timed decorator should return the result of the function it wraps, but it provides None thus breaking functionality.

This type of code breaks:
http://stackoverflow.com/questions/14389154/timed-nose-tests-not-failing-properly/14390409#14390409

@jszakmeister

Can you add a test? How about this:

diff --git a/unit_tests/test_tools.py b/unit_tests/test_tools.py
index 4dadc02..2a6451c 100644
--- a/unit_tests/test_tools.py
+++ b/unit_tests/test_tools.py
@@ -88,6 +88,12 @@ class TestTools(unittest.TestCase):
             time.sleep(.1)
         quick = timed(.2)(quick)

+        def check_result():
+            return 42
+        check_result = timed(.2)(check_result)
+
+        assert 42 == check_result()
+
         quick()
         try:
             too_slow()
@dasickis

Added in the test. Amended existing commit message.

@jszakmeister

LGTM! Thank you!

@jszakmeister jszakmeister merged commit 92b8f96 into nose-devs:master Jan 18, 2013

1 check failed

Details default The Travis build failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.