diff options
| author | Batuhan Taşkaya <btaskaya33@gmail.com> | 2019-05-07 05:02:08 +0300 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-05-17 09:53:24 +0200 |
| commit | 5c19274643dacc0a16e26634aa5dc34bd11a7077 (patch) | |
| tree | 92cf612458e9e85781c07d2973b0bf131c5a9f12 /tests/template_tests | |
| parent | 8d010f39869f107820421631111417298d1c5bb9 (diff) | |
Fixed #30453 -- Fixed crash of simple_tag() and inclusion_tag() when function is wrapped.
getfullargspec() doesn't work with wrapped functions.
Diffstat (limited to 'tests/template_tests')
| -rw-r--r-- | tests/template_tests/test_library.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/template_tests/test_library.py b/tests/template_tests/test_library.py index b7a1f73a2e..9fdb9b7aa1 100644 --- a/tests/template_tests/test_library.py +++ b/tests/template_tests/test_library.py @@ -1,3 +1,5 @@ +import functools + from django.template import Library from django.template.base import Node from django.test import SimpleTestCase @@ -61,6 +63,15 @@ class InclusionTagRegistrationTests(SimpleTestCase): return '' self.assertIn('name', self.library.tags) + def test_inclusion_tag_wrapped(self): + @self.library.inclusion_tag('template.html') + @functools.lru_cache(maxsize=32) + def func(): + return '' + func_wrapped = self.library.tags['func'].__wrapped__ + self.assertIs(func_wrapped, func) + self.assertTrue(hasattr(func_wrapped, 'cache_info')) + class SimpleTagRegistrationTests(SimpleTestCase): @@ -90,6 +101,15 @@ class SimpleTagRegistrationTests(SimpleTestCase): with self.assertRaisesMessage(ValueError, msg): self.library.simple_tag('invalid') + def test_simple_tag_wrapped(self): + @self.library.simple_tag + @functools.lru_cache(maxsize=32) + def func(): + return '' + func_wrapped = self.library.tags['func'].__wrapped__ + self.assertIs(func_wrapped, func) + self.assertTrue(hasattr(func_wrapped, 'cache_info')) + class TagRegistrationTests(SimpleTestCase): |
