summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNatalia <124304+nessita@users.noreply.github.com>2026-02-25 10:37:38 -0300
committerNatalia <124304+nessita@users.noreply.github.com>2026-02-25 13:12:17 -0300
commit703777cbbc268f62083c703fa27fa582b54bcc93 (patch)
tree78cc2fbaa2df9300ce812f75631b45691d674378 /tests
parenta73eed2b5d6dbc78e95482dbd79809b4bd6dd1fd (diff)
[5.2.x] Fixed #36944 -- Removed MAX_LENGTH_HTML and related 5M chars limit references from HTML truncation docs.
Backport of bbc6818bc12f14c1764a7eb68556018195f56b59 from main.
Diffstat (limited to 'tests')
-rw-r--r--tests/utils_tests/test_text.py36
1 files changed, 0 insertions, 36 deletions
diff --git a/tests/utils_tests/test_text.py b/tests/utils_tests/test_text.py
index 11c01874cb..50e205a254 100644
--- a/tests/utils_tests/test_text.py
+++ b/tests/utils_tests/test_text.py
@@ -1,6 +1,5 @@
import json
import sys
-from unittest.mock import patch
from django.core.exceptions import SuspiciousFileOperation
from django.test import SimpleTestCase
@@ -136,23 +135,6 @@ class TestUtilsText(SimpleTestCase):
truncator = text.Truncator("foo</p>")
self.assertEqual("foo</p>", truncator.chars(5, html=True))
- @patch("django.utils.text.Truncator.MAX_LENGTH_HTML", 10_000)
- def test_truncate_chars_html_size_limit(self):
- max_len = text.Truncator.MAX_LENGTH_HTML
- bigger_len = text.Truncator.MAX_LENGTH_HTML + 1
- valid_html = "<p>Joel is a slug</p>" # 14 chars
- perf_test_values = [
- ("</a" + "\t" * (max_len - 6) + "//>", "</a>"),
- ("</p" + "\t" * bigger_len + "//>", "</p>"),
- ("&" * bigger_len, ""),
- ("_X<<<<<<<<<<<>", "_X&lt;&lt;&lt;&lt;&lt;&lt;&lt;…"),
- (valid_html * bigger_len, "<p>Joel is a…</p>"), # 10 chars
- ]
- for value, expected in perf_test_values:
- with self.subTest(value=value):
- truncator = text.Truncator(value)
- self.assertEqual(expected, truncator.chars(10, html=True))
-
def test_truncate_chars_html_with_newline_inside_tag(self):
truncator = text.Truncator(
'<p>The quick <a href="xyz.html"\n id="mylink">brown fox</a> jumped over '
@@ -329,24 +311,6 @@ class TestUtilsText(SimpleTestCase):
self.assertEqual(truncator.words(3, html=True), "hello &gt;&lt;…")
self.assertEqual(truncator.words(4, html=True), "hello &gt;&lt; world")
- @patch("django.utils.text.Truncator.MAX_LENGTH_HTML", 10_000)
- def test_truncate_words_html_size_limit(self):
- max_len = text.Truncator.MAX_LENGTH_HTML
- bigger_len = text.Truncator.MAX_LENGTH_HTML + 1
- valid_html = "<p>Joel is a slug</p>" # 4 words
- perf_test_values = [
- ("</a" + "\t" * (max_len - 6) + "//>", "</a>"),
- ("</p" + "\t" * bigger_len + "//>", "</p>"),
- ("&" * max_len, ""),
- ("&" * bigger_len, ""),
- ("_X<<<<<<<<<<<>", "_X&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&gt;"),
- (valid_html * bigger_len, valid_html * 12 + "<p>Joel is…</p>"), # 50 words
- ]
- for value, expected in perf_test_values:
- with self.subTest(value=value):
- truncator = text.Truncator(value)
- self.assertEqual(expected, truncator.words(50, html=True))
-
def test_wrap(self):
digits = "1234 67 9"
self.assertEqual(text.wrap(digits, 100), "1234 67 9")