summaryrefslogtreecommitdiff
path: root/tests/decorators
diff options
context:
space:
mode:
authorBouke Haarsma <bouke@webatoom.nl>2013-11-01 21:15:41 +0100
committerBaptiste Mispelon <bmispelon@gmail.com>2013-11-11 08:53:09 +0100
commit9b7455e918a437c3db91e88dcbf6d9c93fef96f8 (patch)
tree4cda7466ec20e5255633e7447eaa03ad5450bf24 /tests/decorators
parent6c5f5b9a414b8bdfafc45db5710acf200cca9885 (diff)
downloaddjango-9b7455e918a437c3db91e88dcbf6d9c93fef96f8.tar.gz
Fixed #21351 -- Replaced memoize with Python's lru_cache.
Replaced the custom, untested memoize with a similar decorator from Python's 3.2 stdlib. Although some minor performance degradation (see ticket), it is expected that in the long run lru_cache will outperform memoize once it is implemented in C. Thanks to EvilDMP for the report and Baptiste Mispelon for the idea of replacing memoize with lru_cache.
Diffstat (limited to 'tests/decorators')
-rw-r--r--tests/decorators/tests.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/tests/decorators/tests.py b/tests/decorators/tests.py
index db00f36051..9c654e500a 100644
--- a/tests/decorators/tests.py
+++ b/tests/decorators/tests.py
@@ -1,5 +1,6 @@
from functools import wraps
from unittest import TestCase
+import warnings
from django.contrib.admin.views.decorators import staff_member_required
from django.contrib.auth.decorators import login_required, permission_required, user_passes_test
@@ -58,11 +59,14 @@ full_decorator = compose(
staff_member_required,
# django.utils.functional
- lambda f: memoize(f, {}, 1),
allow_lazy,
lazy,
)
+# suppress the deprecation warning of memoize
+with warnings.catch_warnings(record=True):
+ fully_decorated = memoize(fully_decorated, {}, 1)
+
fully_decorated = full_decorator(fully_decorated)