diff --git a/polyfactory/value_generators/constrained_collections.py b/polyfactory/value_generators/constrained_collections.py index 3953313b..65614e04 100644 --- a/polyfactory/value_generators/constrained_collections.py +++ b/polyfactory/value_generators/constrained_collections.py @@ -46,7 +46,7 @@ def handle_constrained_collection( collection: set[T] | list[T] = set() if (collection_type in (frozenset, set) or unique_items) else [] try: - length = factory.__random__.randint(min_items, max_items) or 1 + length = factory.__random__.randint(min_items, max_items) while (i := len(collection)) < length: if field_build_parameters and len(field_build_parameters) > i: build_params = field_build_parameters[i] diff --git a/tests/constraints/test_frozen_set_constraints.py b/tests/constraints/test_frozen_set_constraints.py index 5af83673..019957f6 100644 --- a/tests/constraints/test_frozen_set_constraints.py +++ b/tests/constraints/test_frozen_set_constraints.py @@ -83,4 +83,4 @@ def test_handle_constrained_set_with_different_types(t_type: Any) -> None: field_meta=FieldMeta(name="test", annotation=frozenset, random=Random()), item_type=t_type, ) - assert len(result) > 0 + assert len(result) >= 0 diff --git a/tests/constraints/test_list_constraints.py b/tests/constraints/test_list_constraints.py index 03edf91a..322035be 100644 --- a/tests/constraints/test_list_constraints.py +++ b/tests/constraints/test_list_constraints.py @@ -89,7 +89,7 @@ def test_handle_constrained_list_with_different_types(t_type: Any) -> None: field_meta=field_meta.children[0], # type: ignore[index] item_type=t_type, ) - assert len(result) > 0 + assert len(result) >= 0 def test_handle_unique_items() -> None: diff --git a/tests/constraints/test_set_constraints.py b/tests/constraints/test_set_constraints.py index e189af9b..95471902 100644 --- a/tests/constraints/test_set_constraints.py +++ b/tests/constraints/test_set_constraints.py @@ -83,4 +83,4 @@ def test_handle_constrained_set_with_different_types(t_type: Any) -> None: field_meta=FieldMeta(name="test", annotation=set, random=Random()), item_type=t_type, ) - assert len(result) > 0 + assert len(result) >= 0