mirror of
https://github.com/ManimCommunity/manim.git
synced 2026-06-22 10:01:47 +00:00
* Removed Container ABC and unnecessary imports * Remove test for container * Remove kwargs from Scene/Mobject * Updated NumberLine and related test * Fix graphscene test by removing unused arg * Fix other TypeError issues in other test cases * Fix doctest * Fixed usages of ParametricFunction * Removed stale references to container * Removed unused parameters passed to Paragraph * Added style parameter to prevent errors from MarkupText/Text * Remove unnecessary style parameter * Update tests/test_number_line.py Co-authored-by: Laith Bahodi <70682032+hydrobeam@users.noreply.github.com> * Remove numberline parameters * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update scene.py * Remove unused font_size param * Removed leftover font_size * Apply suggestions from code review Co-authored-by: friedkeenan <friedkeenan@protonmail.com> * Readded tests for Mobjects/Scene without Container * Applied suggestion for PointCloudMobject * Pass path_string_config only if OpenGL * Readds args to Paragraph, removes **config from VGroup.__init__ calls * Fixed test_scene test case and removed added param * Apply second pass suggestions * Fix incorrect merge in Mobject Co-authored-by: Laith Bahodi <70682032+hydrobeam@users.noreply.github.com> Co-authored-by: friedkeenan <friedkeenan@protonmail.com>
49 lines
1.3 KiB
Python
49 lines
1.3 KiB
Python
import pytest
|
|
|
|
from manim import Mobject
|
|
|
|
|
|
def test_mobject_add():
|
|
"""Test Mobject.add()."""
|
|
"""Call this function with a Container instance to test its add() method."""
|
|
# check that obj.submobjects is updated correctly
|
|
obj = Mobject()
|
|
assert len(obj.submobjects) == 0
|
|
obj.add(Mobject())
|
|
assert len(obj.submobjects) == 1
|
|
obj.add(*(Mobject() for _ in range(10)))
|
|
assert len(obj.submobjects) == 11
|
|
|
|
# check that adding a mobject twice does not actually add it twice
|
|
repeated = Mobject()
|
|
obj.add(repeated)
|
|
assert len(obj.submobjects) == 12
|
|
obj.add(repeated)
|
|
assert len(obj.submobjects) == 12
|
|
|
|
# check that Mobject.add() returns the Mobject (for chained calls)
|
|
assert obj.add(Mobject()) is obj
|
|
obj = Mobject()
|
|
|
|
# a Mobject cannot contain itself
|
|
with pytest.raises(ValueError):
|
|
obj.add(obj)
|
|
|
|
# can only add Mobjects
|
|
with pytest.raises(TypeError):
|
|
obj.add("foo")
|
|
|
|
|
|
def test_mobject_remove():
|
|
"""Test Mobject.remove()."""
|
|
obj = Mobject()
|
|
to_remove = Mobject()
|
|
obj.add(to_remove)
|
|
obj.add(*(Mobject() for _ in range(10)))
|
|
assert len(obj.submobjects) == 11
|
|
obj.remove(to_remove)
|
|
assert len(obj.submobjects) == 10
|
|
obj.remove(to_remove)
|
|
assert len(obj.submobjects) == 10
|
|
|
|
assert obj.remove(Mobject()) is obj
|