Hosted unit tests for pyrevit.coreutils.escape_for_output.
Run from Revit via the DevTools "Run All Tests" button, which discovers every
test_* module in this package. The tests pin how model text is encoded for
output window tables and headings. Ampersands must be encoded before angle
brackets, otherwise the entities written for < and > would be escaped
again and show up as literal < text.
Classes
EscapeForOutputTests
Bases: TestCase
Literal rendering of model text in tables and headings.
Methods:
test_plain_text_is_unchanged()
Names without special characters pass through.
Source code in pyrevitlib/pyrevit/unittests/test_coreutils_escape.py
| def test_plain_text_is_unchanged(self):
"""Names without special characters pass through."""
self.assertEqual("Level 1 - Parking", escape_for_output("Level 1 - Parking"))
|
test_pipe_is_encoded()
A pipe would otherwise split a table cell.
Source code in pyrevitlib/pyrevit/unittests/test_coreutils_escape.py
| def test_pipe_is_encoded(self):
"""A pipe would otherwise split a table cell."""
self.assertEqual("A|B", escape_for_output("A|B"))
|
test_markdown_characters_are_encoded()
Emphasis, code and link openers render literally.
Source code in pyrevitlib/pyrevit/unittests/test_coreutils_escape.py
| def test_markdown_characters_are_encoded(self):
"""Emphasis, code and link openers render literally."""
self.assertEqual(
"*a* _b_ `c` [d]",
escape_for_output("*a* _b_ `c` [d]"),
)
|
test_angle_brackets_are_encoded_once()
Brackets become entities that are not escaped a second time.
Source code in pyrevitlib/pyrevit/unittests/test_coreutils_escape.py
| def test_angle_brackets_are_encoded_once(self):
"""Brackets become entities that are not escaped a second time."""
self.assertEqual("<Unnamed>", escape_for_output("<Unnamed>"))
|
test_ampersand_is_not_read_as_entity()
A name such as "©" shows its characters, not a copyright sign.
Source code in pyrevitlib/pyrevit/unittests/test_coreutils_escape.py
| def test_ampersand_is_not_read_as_entity(self):
"""A name such as "©" shows its characters, not a copyright sign."""
self.assertEqual("&copy;", escape_for_output("©"))
|
test_line_breaks_become_spaces()
A name stays on one table row.
Source code in pyrevitlib/pyrevit/unittests/test_coreutils_escape.py
| def test_line_breaks_become_spaces(self):
"""A name stays on one table row."""
self.assertEqual("A B C D", escape_for_output("A\nB\r\nC\rD"))
|
test_empty_text()
Empty names stay empty.
Source code in pyrevitlib/pyrevit/unittests/test_coreutils_escape.py
| def test_empty_text(self):
"""Empty names stay empty."""
self.assertEqual("", escape_for_output(""))
|
Functions: