MCPcopy
hub / github.com/Textualize/rich / test_escape_escape

Function test_escape_escape

tests/test_markup.py:163–185  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

161
162
163def test_escape_escape():
164 # Escaped escapes (i.e. double backslash)should be treated as literal
165 result = render(r"\\[bold]FOO")
166 assert str(result) == r"\FOO"
167
168 # Single backslash makes the tag literal
169 result = render(r"\[bold]FOO")
170 assert str(result) == "[bold]FOO"
171
172 # Double backslash produces a backslash
173 result = render(r"\\[bold]some text[/]")
174 assert str(result) == r"\some text"
175
176 # Triple backslash parsed as literal backslash plus escaped tag
177 result = render(r"\\\[bold]some text\[/]")
178 assert str(result) == r"\[bold]some text[/]"
179
180 # Backslash escaping only happens when preceding a tag
181 result = render(r"\\")
182 assert str(result) == r"\\"
183
184 result = render(r"\\\\")
185 assert str(result) == r"\\\\"
186
187
188def test_events():

Callers

nothing calls this directly

Calls 1

renderFunction · 0.90

Tested by

no test coverage detected