From 6792affdb7f726bcc2919044aedb0be4e9e3383a Mon Sep 17 00:00:00 2001 From: Guillaume Vauvert Date: Fri, 3 Jan 2025 08:50:19 +0000 Subject: [PATCH] Issue-4087 Improve previous test instead of adding a new one --- tests/module/mobject/mobject/test_mobject.py | 45 ++++++-------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/tests/module/mobject/mobject/test_mobject.py b/tests/module/mobject/mobject/test_mobject.py index 8b8cf42a0f..b00b4133c5 100644 --- a/tests/module/mobject/mobject/test_mobject.py +++ b/tests/module/mobject/mobject/test_mobject.py @@ -3,7 +3,7 @@ import numpy as np import pytest -from manim import DL, UR, Circle, Mobject, Rectangle, Square, VGroup +from manim import DL, DR, UL, UR, Circle, Mobject, Rectangle, Square, VGroup def test_mobject_add(): @@ -136,18 +136,19 @@ def test_mobject_dimensions_nested_mobjects(): def test_mobject_dimensions_mobjects_with_no_points_are_at_origin(): - rect = Rectangle(width=2, height=3) - rect.move_to([-4, -5, 0]) - outer_group = VGroup(rect) + for direction in [DL, DR, UL, UR]: + rect = Rectangle(width=2, height=3) + rect.move_to(direction * 10) + outer_group = VGroup(rect) - # This is as one would expect - assert outer_group.width == 2 - assert outer_group.height == 3 + # This is as one would expect + assert outer_group.width == 2 + assert outer_group.height == 3 - # Adding a mobject with no points does not change its size - outer_group.add(VGroup()) - assert outer_group.width == 2 - assert outer_group.height == 3 + # Adding a mobject with no points does not change its size + outer_group.add(VGroup()) + assert outer_group.width == 2 + assert outer_group.height == 3 def test_mobject_dimensions_has_points_and_children(): @@ -165,25 +166,3 @@ def test_mobject_dimensions_has_points_and_children(): assert inner_rect.width == 2 assert inner_rect.height == 1 assert inner_rect.depth == 0 - - -def test_mobject_width_height(): - for flow_order in ["ur", "dl"]: - for is_reversed in [False, True]: - # create a vgroup with some sub-elements - vgroup = VGroup() - sub_vgroup = VGroup() - square = Square(side_length=2.0) - sub_elements = [sub_vgroup, square] - if is_reversed: - sub_elements.reverse() - vgroup.add(sub_elements) - # arrange them to move sub-objects all above or below zero - direction = UR if flow_order == "ur" else DL - vgroup.shift(direction * 10) - vgroup.arrange_in_grid(rows=2, cols=2, flow_order=flow_order) - # These measures should be 2. - assert vgroup.length_over_dim(0) == pytest.approx(2.0) - assert vgroup.length_over_dim(1) == pytest.approx(2.0) - assert vgroup.height == pytest.approx(2.0) - assert vgroup.width == pytest.approx(2.0)