mirror of
https://github.com/ManimCommunity/manim.git
synced 2026-06-22 10:01:47 +00:00
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.8.0 → v0.9.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.8.0...v0.9.1) - [github.com/pre-commit/mirrors-mypy: v1.13.0 → v1.14.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.13.0...v1.14.1) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * enh: ignore ruff lint rule A005 (module shadowing standard library module) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Benjamin Hackl <devel@benjamin-hackl.at>
48 lines
1.4 KiB
Python
48 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
from manim import MarkupText
|
|
|
|
|
|
def test_good_markup():
|
|
"""Test creation of valid :class:`MarkupText` object"""
|
|
try:
|
|
text1 = MarkupText("<b>foo</b>")
|
|
text2 = MarkupText("foo")
|
|
success = True
|
|
except ValueError:
|
|
success = False
|
|
assert success, "'<b>foo</b>' and 'foo' should not fail validation"
|
|
|
|
|
|
def test_special_tags_markup():
|
|
"""Test creation of valid :class:`MarkupText` object with unofficial tags"""
|
|
try:
|
|
text1 = MarkupText('<color col="RED">foo</color>')
|
|
text1 = MarkupText('<gradient from="RED" to="YELLOW">foo</gradient>')
|
|
success = True
|
|
except ValueError:
|
|
success = False
|
|
assert success, (
|
|
'\'<color col="RED">foo</color>\' and \'<gradient from="RED" to="YELLOW">foo</gradient>\' should not fail validation'
|
|
)
|
|
|
|
|
|
def test_unbalanced_tag_markup():
|
|
"""Test creation of invalid :class:`MarkupText` object (unbalanced tag)"""
|
|
try:
|
|
text = MarkupText("<b>foo")
|
|
success = False
|
|
except ValueError:
|
|
success = True
|
|
assert success, "'<b>foo' should fail validation"
|
|
|
|
|
|
def test_invalid_tag_markup():
|
|
"""Test creation of invalid :class:`MarkupText` object (invalid tag)"""
|
|
try:
|
|
text = MarkupText("<invalidtag>foo</invalidtag>")
|
|
success = False
|
|
except ValueError:
|
|
success = True
|
|
|
|
assert success, "'<invalidtag>foo</invalidtag>' should fail validation"
|