Skip to content

Commit 162f0aa

Browse files
committed
TEST: Added test for __sub__ to increase coverage
1 parent 4b42974 commit 162f0aa

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

sectionproperties/tests/test_sections.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from sectionproperties.pre.library.steel_sections import *
77
from sectionproperties.pre.library.nastran_sections import *
88
from sectionproperties.analysis.section import Section
9-
from sectionproperties.pre.pre import Material
9+
from sectionproperties.pre.pre import DEFAULT_MATERIAL, Material
1010
from sectionproperties.pre.rhino import load_3dm, load_brep_encoding
1111
from shapely.geometry import (
1212
Polygon,
@@ -44,14 +44,15 @@
4444
overlay_geom.create_mesh([50])
4545
overlay_sec = Section(overlay_geom)
4646

47+
steel = Material("steel", 200e3, 0.3, 7.85e-6, 400, "grey")
48+
4749

4850
def test_material_persistence():
4951
# Test ensures that the material attribute gets transformed
5052
# through all of the Geometry transformation methods, each which
5153
# returns a new Geometry object.
5254
# The material assignment should persist through all of the
5355
# transformations
54-
steel = Material("steel", 200e3, 0.3, 7.85e-6, 400, "grey")
5556
big_sq.material = steel
5657
new_geom = (
5758
big_sq.align_to(small_sq, on="left", inner=False)
@@ -72,6 +73,21 @@ def test_for_incidental_holes():
7273
assert len(nested_geom.holes) == 0
7374

7475

76+
def test__sub__():
77+
small_hole.material = steel
78+
top_left = small_hole.align_to(big_sq, on="left").align_to(big_sq, on="top").shift_section(20, -20)
79+
top_right = top_left.shift_section(x_offset=200)
80+
81+
compound = big_sq - top_left
82+
compound = compound + top_left
83+
compound = compound - top_right
84+
compound = compound + top_right
85+
86+
assert len(compound.control_points) == 3
87+
# Incomplete test to validate that the iterative __sub__ produces
88+
# three distinct regions with proper material assignments
89+
90+
7591
def test_geometry_from_points():
7692
# Geometry.from_points() tests a shape with exactly one exterior
7793
# and an arbitrary number of interiors being built from the legacy

0 commit comments

Comments
 (0)