summaryrefslogtreecommitdiff
path: root/tests/template_tests
diff options
context:
space:
mode:
authorDavid Sanders <shang.xiao.sanders@gmail.com>2023-04-26 22:17:57 +1000
committerGitHub <noreply@github.com>2023-04-26 14:17:57 +0200
commit7d0e56620882c207998a41ac07ec5da572045b31 (patch)
tree690f4d6e68dcc4fa057a6225cf214f9b17be6447 /tests/template_tests
parent18a7f2c711529f8e43c36190a5e2479f13899749 (diff)
downloaddjango-7d0e56620882c207998a41ac07ec5da572045b31.tar.gz
Fixed #34518 -- Fixed crash of random() template filter with an empty list.
Diffstat (limited to 'tests/template_tests')
-rw-r--r--tests/template_tests/filter_tests/test_random.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/template_tests/filter_tests/test_random.py b/tests/template_tests/filter_tests/test_random.py
index 785f2d6a2f..8f197e6f13 100644
--- a/tests/template_tests/filter_tests/test_random.py
+++ b/tests/template_tests/filter_tests/test_random.py
@@ -24,3 +24,8 @@ class RandomTests(SimpleTestCase):
"random02", {"a": ["a&b", "a&b"], "b": [mark_safe("a&b"), mark_safe("a&b")]}
)
self.assertEqual(output, "a&b a&b")
+
+ @setup({"empty_list": "{{ list|random }}"})
+ def test_empty_list(self):
+ output = self.engine.render_to_string("empty_list", {"list": []})
+ self.assertEqual(output, "")