@@ -152,12 +152,7 @@ def test_inspect_module_should_unwrap_decorated_constructor():
152152
153153
154154def test_inspect_module_should_find_methods ():
155- """ Test that methods are detected including static methods
156-
157- This test case assumes that the methods will be sorted by type as follow:
158- 1a - instance methods (special methods aka "dunder")
159- 1b - all other instance methods
160- 2 - static methods """
155+ """ Test that methods are detected including static methods """
161156
162157 domain_items_by_fqn : Dict [str , UmlItem ] = {}
163158 domain_relations : List [UmlRelation ] = []
@@ -175,7 +170,28 @@ def test_inspect_module_should_find_methods():
175170 point_umlitem : UmlClass = domain_items_by_fqn ['tests.modules.withmethods.withmethods.Point' ]
176171 assert len (point_umlitem .methods ) == 3
177172
178- assert point_umlitem .methods [0 ].name == '__init__' # 1a - Instance method (special)
179- assert point_umlitem .methods [1 ].name == 'get_coordinates' # 1b - Instance method (regular)
180- assert point_umlitem .methods [2 ].name == 'from_values' # 2 - Static method
173+ assert point_umlitem .methods [0 ].name == 'from_values'
174+ assert point_umlitem .methods [1 ].name == 'get_coordinates'
175+ assert point_umlitem .methods [2 ].name == '__init__'
176+ # FIXME: use 'assert_method' once UmlMethod restructured
177+
178+
179+ def test_inspect_module_inherited_methods ():
180+ """ Test that inherited methods are not included in subclasses """
181+
182+ domain_items_by_fqn : Dict [str , UmlItem ] = {}
183+ domain_relations : List [UmlRelation ] = []
184+ inspect_module (
185+ import_module ('tests.modules.withmethods.withinheritedmethods' ),
186+ 'tests.modules.withmethods.withinheritedmethods' ,
187+ domain_items_by_fqn , domain_relations
188+ )
189+
190+ # ThreeDimensionalCoordinates UmlClass
191+ coordinates_3d_umlitem : UmlClass = domain_items_by_fqn ['tests.modules.withmethods.withinheritedmethods.ThreeDimensionalPoint' ]
192+ assert len (coordinates_3d_umlitem .methods ) == 3
193+
194+ assert coordinates_3d_umlitem .methods [0 ].name == '__init__'
195+ assert coordinates_3d_umlitem .methods [1 ].name == 'move'
196+ assert coordinates_3d_umlitem .methods [2 ].name == 'check_positive'
181197 # FIXME: use 'assert_method' once UmlMethod restructured
0 commit comments