Skip to content

Commit 17b4183

Browse files
wmaynerclaude
andcommitted
Add test for try_len with multiple iterables
Tests the minimum-length behavior when try_len is called with multiple iterables, ported from the experimental test_parallel2.py file. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 97ee0fe commit 17b4183

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

test/test_utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import numpy as np
22
from hypothesis import given
3+
from hypothesis import strategies as st
34

45
from pyphi import config
56
from pyphi import utils
@@ -130,3 +131,13 @@ def test_np_hashable():
130131
def test_try_len(iterable):
131132
expected = len(iterable) if hasattr(iterable, "__len__") else None
132133
assert utils.try_len(iterable) == expected
134+
135+
136+
@given(st.lists(iterable_or_list(anything())))
137+
def test_try_len_multiple_iterables(iterables):
138+
"""Test try_len returns minimum length when given multiple iterables."""
139+
expected = min(
140+
(len(it) for it in iterables if hasattr(it, "__len__")),
141+
default=None,
142+
)
143+
assert utils.try_len(*iterables) == expected

0 commit comments

Comments
 (0)