def language_human_names(draw: _DrawType):
    """
    Generates a `Language` object with an arbitrary two-letter string as the code and
    a human name for the text ostensibly written in that language.
    :param draw: Hidden argument, used by Hypothesis.
    """
    return Language(draw(human_names()), draw(two_letter_codes()))
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")])