Skip to content

Commit aef07ca

Browse files
committed
Revert functional test for comprehension ==> this now works with new util functions
1 parent 780740b commit aef07ca

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

tests/pyreverse/functional/class_diagrams/associations/comprehensions.mmd

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
classDiagram
2+
class AggregationContainer {
3+
component_dict : dict[str, Component]
4+
components : list[Component]
5+
components_set : set[Component]
6+
lazy_components : Generator[Component]
7+
}
28
class AssociationContainer {
39
component_dict : dict[int, Component]
410
components : list[Component]
@@ -22,3 +28,7 @@ classDiagram
2228
Component --* CompositionContainer : component_dict
2329
Component --* CompositionContainer : components_set
2430
Component --* CompositionContainer : lazy_components
31+
Component --o AggregationContainer : components
32+
Component --o AggregationContainer : component_dict
33+
Component --o AggregationContainer : components_set
34+
Component --o AggregationContainer : lazy_components

tests/pyreverse/functional/class_diagrams/associations/comprehensions.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ def __init__(self):
1717
self.components_set: set[Component]
1818
self.lazy_components: Generator[Component]
1919

20+
class AggregationContainer:
21+
"""Comprehensions using existing objects - aggregation."""
22+
def __init__(self, existing_components: list[Component]):
23+
# Aggregation: comprehensions using existing objects (not creating)
24+
self.components: list[Component] = [comp for comp in existing_components]
25+
self.component_dict: dict[str, Component] = {f"key_{i}": comp for i, comp in enumerate(existing_components)}
26+
self.components_set: set[Component] = {comp for comp in existing_components}
27+
self.lazy_components: Generator[Component] = (comp for comp in existing_components)
28+
2029
class CompositionContainer:
2130
"""Comprehensions creating new objects - composition."""
2231
def __init__(self):

0 commit comments

Comments
 (0)