Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Rewrote unstable tests for :mod:`.text_mobject` to be non-graphical (#2982)

Benjamin Hacklb3b90ef34683
diff --git a/tests/test_graphical_units/control_data/text/Text2Color.npz b/tests/test_graphical_units/control_data/text/Text2Color.npz
deleted file mode 100644
index 590b90517..000000000
Binary files a/tests/test_graphical_units/control_data/text/Text2Color.npz and /dev/null differ
diff --git a/tests/test_graphical_units/control_data/text/text_color_inheritance.npz b/tests/test_graphical_units/control_data/text/text_color_inheritance.npz
deleted file mode 100644
index e453cc9a8..000000000
Binary files a/tests/test_graphical_units/control_data/text/text_color_inheritance.npz and /dev/null differ
diff --git a/tests/test_graphical_units/test_text.py b/tests/test_graphical_units/test_text.py
index 4d319a27b..606ff4251 100644
--- a/tests/test_graphical_units/test_text.py
+++ b/tests/test_graphical_units/test_text.py
@@ -1,35 +1,34 @@
import pytest
+from colour import Color
-from manim import *
-from manim.utils.testing.frames_comparison import frames_comparison
+from manim import RED, MarkupText, Text, VGroup, VMobject
__module_test__ = "text"
- not sys.platform.startswith("linux"),
- reason="MacOS and Windows render fonts differently, so they need separate comparison data.",
-)
-@frames_comparison
-def test_Text2Color(scene):
- scene.add(Text("this is a text with spaces!", t2c={"spaces": RED}))
+def test_Text2Color():
+ txt = Text(
+ "this is a text with spaces!",
+ t2c={"spaces": RED},
+ stroke_width=1,
+ disable_ligatures=True,
+ )
+ assert len(txt.submobjects) == 29
+ assert all(char.fill_color == Color("#ffffff") for char in txt[:4]) # "this"
+ assert all(char.fill_color == Color(RED) for char in txt[-7:-1]) # "spaces"
+ assert txt[-1].fill_color == Color("#ffffff") # "!"
- not sys.platform.startswith("linux"),
- reason="MacOS and Windows render fonts differently, so they need separate comparison data.",
-)
-@frames_comparison
-def test_text_color_inheritance(scene):
+def test_text_color_inheritance():
"""Test that Text and MarkupText correctly inherit colour from
their parent class."""
VMobject.set_default(color=RED)
# set both to a singular font so that the tests agree.
text = Text("test_color_inheritance", font="Dejavu Sans")
markup_text = MarkupText("test_color_inheritance", font="Dejavu Sans")
- vgr = VGroup(text, markup_text).arrange()
+
+ assert all(char.fill_color == Color(RED) for char in text)
+ assert all(char.fill_color == Color(RED) for char in markup_text)
# reset the default color so that future tests aren't affected by this change.
VMobject.set_default()
-
- scene.add(vgr)