Skip to content

Commit 8b5d831

Browse files
committed
Issue-4087 Improve previous test instead of adding a new one
1 parent 7337501 commit 8b5d831

File tree

1 file changed

+12
-33
lines changed

1 file changed

+12
-33
lines changed

tests/module/mobject/mobject/test_mobject.py

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import numpy as np
44
import pytest
55

6-
from manim import DL, UR, Circle, Mobject, Rectangle, Square, VGroup
6+
from manim import DL, DR, UL, UR, Circle, Mobject, Rectangle, Square, VGroup
77

88

99
def test_mobject_add():
@@ -136,18 +136,19 @@ def test_mobject_dimensions_nested_mobjects():
136136

137137

138138
def test_mobject_dimensions_mobjects_with_no_points_are_at_origin():
139-
rect = Rectangle(width=2, height=3)
140-
rect.move_to([-4, -5, 0])
141-
outer_group = VGroup(rect)
139+
for direction in [DL, DR, UL, UR]:
140+
rect = Rectangle(width=2, height=3)
141+
rect.move_to(direction * 10)
142+
outer_group = VGroup(rect)
142143

143-
# This is as one would expect
144-
assert outer_group.width == 2
145-
assert outer_group.height == 3
144+
# This is as one would expect
145+
assert outer_group.width == 2
146+
assert outer_group.height == 3
146147

147-
# Adding a mobject with no points does not change its size
148-
outer_group.add(VGroup())
149-
assert outer_group.width == 2
150-
assert outer_group.height == 3
148+
# Adding a mobject with no points does not change its size
149+
outer_group.add(VGroup())
150+
assert outer_group.width == 2
151+
assert outer_group.height == 3
151152

152153

153154
def test_mobject_dimensions_has_points_and_children():
@@ -165,25 +166,3 @@ def test_mobject_dimensions_has_points_and_children():
165166
assert inner_rect.width == 2
166167
assert inner_rect.height == 1
167168
assert inner_rect.depth == 0
168-
169-
170-
def test_mobject_width_height():
171-
for flow_order in ["ur", "dl"]:
172-
for is_reversed in [False, True]:
173-
# create a vgroup with some sub-elements
174-
vgroup = VGroup()
175-
sub_vgroup = VGroup()
176-
square = Square(side_length=2.0)
177-
sub_elements = [sub_vgroup, square]
178-
if is_reversed:
179-
sub_elements.reverse()
180-
vgroup.add(sub_elements)
181-
# arrange them to move sub-objects all above or below zero
182-
direction = UR if flow_order == "ur" else DL
183-
vgroup.shift(direction * 10)
184-
vgroup.arrange_in_grid(rows=2, cols=2, flow_order=flow_order)
185-
# These measures should be 2.
186-
assert vgroup.length_over_dim(0) == pytest.approx(2.0)
187-
assert vgroup.length_over_dim(1) == pytest.approx(2.0)
188-
assert vgroup.height == pytest.approx(2.0)
189-
assert vgroup.width == pytest.approx(2.0)

0 commit comments

Comments
 (0)