summaryrefslogtreecommitdiff
path: root/tests/decorators
diff options
context:
space:
mode:
authorMarc Tamlyn <marc.tamlyn@gmail.com>2014-02-09 10:12:22 +0000
committerMarc Tamlyn <marc.tamlyn@gmail.com>2014-02-09 10:12:22 +0000
commit46a87214caf07f8b21adce5d1733d5d598d16e26 (patch)
treece040740993e439406fc2612645205a92927aa7e /tests/decorators
parent6fe26bd3ee75a6d804ca3861181ad61b1cca45ea (diff)
parent14940fdd96e77778cacdf0963913a343b1f33b9a (diff)
downloaddjango-46a87214caf07f8b21adce5d1733d5d598d16e26.tar.gz
Merge pull request #1997 from dpwrussell/method_decorator_args_fix
Used available_attrs in method_decorator
Diffstat (limited to 'tests/decorators')
-rw-r--r--tests/decorators/tests.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/decorators/tests.py b/tests/decorators/tests.py
index 9c654e500a..bd4fa4756c 100644
--- a/tests/decorators/tests.py
+++ b/tests/decorators/tests.py
@@ -1,4 +1,4 @@
-from functools import wraps
+from functools import wraps, update_wrapper
from unittest import TestCase
import warnings
@@ -174,6 +174,16 @@ def myattr2_dec(func):
myattr2_dec_m = method_decorator(myattr2_dec)
+class ClsDec(object):
+ def __init__(self, myattr):
+ self.myattr = myattr
+
+ def __call__(self, f):
+
+ def wrapped():
+ return f() and self.myattr
+ return update_wrapper(wrapped, f)
+
class MethodDecoratorTests(TestCase):
"""
@@ -214,6 +224,16 @@ class MethodDecoratorTests(TestCase):
self.assertEqual(Test.method.__doc__, 'A method')
self.assertEqual(Test.method.__name__, 'method')
+ # Test for argumented decorator
+ def test_argumented(self):
+ class Test(object):
+ @method_decorator(ClsDec(False))
+ def method(self):
+ return True
+
+ # t = Test()
+ self.assertEqual(Test().method(), False)
+
class XFrameOptionsDecoratorsTests(TestCase):
"""