diff --git a/tests/test_add_connections.py b/tests/test_add_connections.py index 454bf5d..5fa8f7f 100644 --- a/tests/test_add_connections.py +++ b/tests/test_add_connections.py @@ -44,6 +44,7 @@ def test_AddLists(use_graph): outs = AddOne(lst1.outs + lst2.outs) assert isinstance(outs.value, CombinedConnections) + assert len(outs.value) == 2 assert len(outs.value.connections) == 2 assert outs.value.connections[0].instance is lst1 assert outs.value.connections[0].attribute == "outs" diff --git a/znflow/base.py b/znflow/base.py index d69446d..80e83f4 100644 --- a/znflow/base.py +++ b/znflow/base.py @@ -331,6 +331,9 @@ def __radd__(self, other): def __getitem__(self, item): return dataclasses.replace(self, item=item) + def __len__(self) -> int: + return len(self.connections) + def __iter__(self): raise TypeError(f"Can not iterate over {self}.")