How to use the mimesis.enums.Gender.MALE function in mimesis

To help you get started, we’ve selected a few mimesis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lk-geimfari / mimesis / tests / test_builtins / ru / test_russia_spec.py View on Github external
        Gender.MALE,
    ],
)
def test_patronymic(russia, gender):
    result = russia.patronymic(gender=gender)

    assert result is not None
    assert len(result) >= 4

    with pytest.raises(NonEnumerableError):
        russia.patronymic(gender='nil')
github lk-geimfari / mimesis / tests / test_providers / test_person.py View on Github external
            Gender.MALE,
        ],
    )
    def test_first_name(self, person, gender):
        result = person.first_name(gender=gender)
        assert result in person._data['names'][gender.value]
github lk-geimfari / mimesis / tests / test_providers / test_base.py View on Github external
            (Gender.MALE, 'male'),
            (Gender.FEMALE, 'female'),
            (None, ['female', 'male']),
        ],
    )
    def test_validate_enum(self, base_data_provider, gender, excepted):
        result = base_data_provider._validate_enum(gender, Gender)

        assert (result == excepted) or (result in excepted)
        assert result in [item.value for item in Gender]

        with pytest.raises(NonEnumerableError):
            base_data_provider._validate_enum('', '')
github lk-geimfari / mimesis / tests / test_providers / test_payment.py View on Github external
            Gender.MALE,
            Gender.FEMALE,
        ],
    )
    def test_credit_card_owner(self, payment, gender):
        result = payment.credit_card_owner(gender=gender)
        assert isinstance(result, dict)
        assert 'owner' in result
        assert 'credit_card' in result
        assert 'expiration_date' in result
github lk-geimfari / mimesis / tests / test_providers / test_person.py View on Github external
def test_surname(self, p1, p2):
        assert p1.surname() == p2.surname()
        assert p1.last_name(gender=Gender.MALE) == \
               p2.last_name(gender=Gender.MALE)
github timkpaine / lantern / lantern / data / other.py View on Github external
def person(locale=None):
    if locale is None:
        locales = _MIMESIS_LOCALES
    else:
        locales = [locale]
    p = mimesis.Person(locale=choice(locales))
    gender = choice(['Male'] * 20 + ['Female'] * 21 + ['Other'])

    g = mimesis.enums.Gender.MALE if gender.lower() == 'male' else mimesis.enums.Gender.FEMALE
    first = p.name(g)
    last = p.last_name(g)

    return {
        'first_name': first,
        'last_name': last,
        'name': first + ' ' + last,  # western
        'age': p.age(),
        'gender': gender,
        'id': p.identifier(),
        'occupation': p.occupation(),
        'telephone': p.telephone(),
        'title': p.title(g),
        'username': p.username(),
        'university': p.university(),
    }
github lk-geimfari / mimesis / mimesis / builtins / pl.py View on Github external
if 1800 <= year <= 1899:
            month += 80
        elif 2000 <= year <= 2099:
            month += 20
        elif 2100 <= year <= 2199:
            month += 40
        elif 2200 <= year <= 2299:
            month += 60

        pesel_digits += [int(d) for d in '{:02d}'.format(month)]
        pesel_digits += [int(d) for d in '{:02d}'.format(day)]
        series_number = self.random.randint(0, 999)
        pesel_digits += [int(d) for d in '{:03d}'.format(series_number)]

        if gender == Gender.MALE:
            gender_digit = self.random.choice((1, 3, 5, 7, 9))
        elif gender == Gender.FEMALE:
            gender_digit = self.random.choice((0, 2, 4, 6, 8))
        else:
            gender_digit = self.random.choice(range(10))

        pesel_digits.append(gender_digit)
        pesel_coeffs = (9, 7, 3, 1, 9, 7, 3, 1, 9, 7)
        sum_v = sum([nc * nd for nc, nd in
                     zip(pesel_coeffs, pesel_digits)])
        checksum_digit = sum_v % 10
        pesel_digits.append(checksum_digit)
        return ''.join(str(d) for d in pesel_digits)