File: test_example_6.py

package info (click to toggle)
python-polyfactory 3.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,976 kB
  • sloc: python: 11,113; makefile: 102; sh: 34
file content (19 lines) | stat: -rw-r--r-- 417 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from dataclasses import dataclass

from polyfactory.factories import DataclassFactory


@dataclass
class Owner:
    cars: tuple[str, ...]


class OwnerFactory(DataclassFactory[Owner]):
    __randomize_collection_length__ = True
    __min_collection_length__ = 2
    __max_collection_length__ = 5


def test_randomized_collection_length() -> None:
    owner = OwnerFactory.build()
    assert 2 <= len(owner.cars) <= 5