MCPcopy
hub / github.com/django/django / test_truncate_chars_html

Method test_truncate_chars_html

tests/utils_tests/test_text.py:98–137  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

96 )
97
98 def test_truncate_chars_html(self):
99 truncator = text.Truncator(
100 '<p id="par"><strong><em>The quick brown fox jumped over the lazy dog.</em>'
101 "</strong></p>"
102 )
103 self.assertEqual(
104 '<p id="par"><strong><em>The quick brown fox jumped over the lazy dog.</em>'
105 "</strong></p>",
106 truncator.chars(80, html=True),
107 )
108 self.assertEqual(
109 '<p id="par"><strong><em>The quick brown fox jumped over the lazy dog.</em>'
110 "</strong></p>",
111 truncator.chars(46, html=True),
112 )
113 self.assertEqual(
114 '<p id="par"><strong><em>The quick brown fox jumped over the lazy dog…</em>'
115 "</strong></p>",
116 truncator.chars(45, html=True),
117 )
118 self.assertEqual(
119 '<p id="par"><strong><em>The quick…</em></strong></p>',
120 truncator.chars(10, html=True),
121 )
122 self.assertEqual(
123 '<p id="par"><strong><em>…</em></strong></p>',
124 truncator.chars(1, html=True),
125 )
126 self.assertEqual("", truncator.chars(0, html=True))
127 self.assertEqual("", truncator.chars(-1, html=True))
128 self.assertEqual(
129 '<p id="par"><strong><em>The qu....</em></strong></p>',
130 truncator.chars(10, "....", html=True),
131 )
132 self.assertEqual(
133 '<p id="par"><strong><em>The quick </em></strong></p>',
134 truncator.chars(10, "", html=True),
135 )
136 truncator = text.Truncator("foo</p>")
137 self.assertEqual("foo</p>", truncator.chars(5, html=True))
138
139 def test_truncate_chars_html_with_newline_inside_tag(self):
140 truncator = text.Truncator(

Callers

nothing calls this directly

Calls 1

charsMethod · 0.95

Tested by

no test coverage detected