示例#1
0
def internationalized_texts(draw: _DrawType):
    """
    Generates an `InternationalizedText` object with a list of `Language` objects
    within (representing a multilingual string).
    :param draw: Hidden argument, used by Hypothesis.
    """
    return InternationalizedText(draw(lists(languages(), min_size=1, max_size=3)))
def party_lists(draw: _DrawType, num_parties: int):
    """
    Generates a `List[Party]` of the requested length.
    :param draw: Hidden argument, used by Hypothesis.
    :param num_parties: Number of parties to generate in the list.
    """
    party_names = [f"Party{n}" for n in range(num_parties)]
    party_abbrvs = [f"P{n}" for n in range(num_parties)]

    assert num_parties > 0

    return [
        Party(
            object_id=str(draw(uuids())),
            name=InternationalizedText([Language(party_names[i], "en")]),
            abbreviation=party_abbrvs[i],
            color=None,
            logo_uri=draw(urls()),
        ) for i in range(num_parties)
    ]
示例#3
0
def _str_to_internationalized_text_en(s: str) -> InternationalizedText:
    return InternationalizedText([Language(s, language="en")])