Skip to content

Commit

Permalink
Add Gender support for Latvian (lv_LV) names (#1922)
Browse files Browse the repository at this point in the history
Signed-off-by: Oskars Pakers <oskars.pakers@gmail.com>
  • Loading branch information
OskarsPakers authored Oct 9, 2023
1 parent cd24cae commit ec1832f
Show file tree
Hide file tree
Showing 2 changed files with 149 additions and 14 deletions.
104 changes: 90 additions & 14 deletions faker/providers/person/lv_LV/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Provider(PersonProvider):
"{{last_name}}, {{first_name}}",
)

first_names = (
first_names_male = (
"Ādams",
"Ādolfs",
"Agris",
Expand Down Expand Up @@ -133,6 +133,9 @@ class Provider(PersonProvider):
"Voldemārs",
"Ziedonis",
"Žanis",
)

first_names_female = (
"Agnese",
"Aiga",
"Aija",
Expand All @@ -151,7 +154,6 @@ class Provider(PersonProvider):
"Ārija",
"Ausma",
"Austra",
"Baba",
"Baiba",
"Berta",
"Biruta",
Expand Down Expand Up @@ -283,8 +285,24 @@ class Provider(PersonProvider):
"Zigrīda",
)

last_names = (
first_names = first_names_male + first_names_female

last_names_unisex = (
"Ābele",
"Bite",
"Caune",
"Krūze",
"Lapsa",
"Liepa",
"Paegle",
"Priede",
"Roze",
"Skuja",
"Vīksna",
"Zvaigzne",
)

last_names_male = (
"Āboliņš",
"Ābols",
"Alksnis",
Expand All @@ -297,9 +315,7 @@ class Provider(PersonProvider):
"Baltiņš",
"Bērziņš",
"Birznieks",
"Bite",
"Briedis",
"Caune",
"Celmiņš",
"Celms",
"Cīrulis",
Expand All @@ -318,38 +334,30 @@ class Provider(PersonProvider):
"Krieviņš",
"Krievs",
"Krūmiņš",
"Krūze",
"Kundziņš",
"Lācis",
"Lagzdiņš",
"Lapsa",
"Līcis",
"Liepa",
"Liepiņš",
"Lukstiņš",
"Lūsis",
"Paegle",
"Pērkons",
"Podnieks",
"Polis",
"Priede",
"Priedītis",
"Puriņš",
"Purmals",
"Riekstiņš",
"Roze",
"Rozītis",
"Rubenis",
"Rudzītis",
"Saulītis",
"Siliņš",
"Skuja",
"Skujiņš",
"Sproģis",
"Strazdiņš",
"Turiņš",
"Vanags",
"Vīksna",
"Vilciņš",
"Vilks",
"Vītoliņš",
Expand All @@ -360,6 +368,74 @@ class Provider(PersonProvider):
"Zeltiņš",
"Ziemelis",
"Zirnis",
"Zvaigzne",
"Zvirbulis",
)

last_names_female = (
"Āboliņa",
"Ābola",
"Alksne",
"Apine",
"Apsīte",
"Auniņa",
"Auziņa",
"Avotiņa",
"Balode",
"Bērziņa",
"Birzniece",
"Briede",
"Celmiņa",
"Celma",
"Cīrule",
"Dzene",
"Dūmiņa",
"Eglīte",
"Jaunzema",
"Kalēja",
"Kalniņa",
"Kaņepa",
"Kārkliņa",
"Kauliņa",
"Kļaviņa",
"Krastiņa",
"Krēsliņa",
"Krieviņa",
"Krieva",
"Krūmiņa",
"Kundziņa",
"Lāce",
"Lagzdiņa",
"Līce",
"Liepiņa",
"Lukstiņa",
"Lūse",
"Pērkona",
"Podniece",
"Pole",
"Priedīte",
"Puriņa",
"Purmale",
"Riekstiņa",
"Rozīte",
"Rubene",
"Rudzīte",
"Saulīte",
"Siliņa",
"Skujiņa",
"Sproģe",
"Strazdiņa",
"Turiņa",
"Vanaga",
"Vilciņa",
"Vītoliņa",
"Vītola",
"Zaķe",
"Zālīte",
"Zariņa",
"Zeltiņa",
"Ziemele",
"Zirne",
"Zvirbule",
)

last_names = last_names_male + last_names_female + last_names_unisex
59 changes: 59 additions & 0 deletions tests/providers/test_person.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from faker.providers.person.ga_IE import Provider as GaIEProvider
from faker.providers.person.he_IL import Provider as HeILProvider
from faker.providers.person.hy_AM import Provider as HyAmProvider
from faker.providers.person.lv_LV import Provider as LvProvider
from faker.providers.person.ne_NP import Provider as NeProvider
from faker.providers.person.nl_BE import Provider as NlBEProvider
from faker.providers.person.or_IN import Provider as OrINProvider
Expand Down Expand Up @@ -288,6 +289,64 @@ def test_person(self):
assert all(isinstance(s, str) for s in last_name_pair)


class TestLvLV(unittest.TestCase):
def setUp(self):
self.fake = Faker("lv_LV")
Faker.seed(0)

def test_first_name(self):
# General first name
name = self.fake.first_name()
assert name
self.assertIsInstance(name, str)
assert name in LvProvider.provider.first_names

Check failure on line 302 in tests/providers/test_person.py

View workflow job for this annotation

GitHub Actions / test_ubuntu (3.11)

AttributeError

# Females first name
name = self.fake.first_name_female()
assert name
self.assertIsInstance(name, str)
assert name in LvProvider.provider.first_names
assert name in LvProvider.provider.first_names_female

# Male first name
name = self.fake.first_name_male()
assert name
self.assertIsInstance(name, str)
assert name in LvProvider.provider.first_names
assert name in LvProvider.provider.first_names_male

def test_last_name(self):
# General last name.
name = self.fake.last_name()
assert name
self.assertIsInstance(name, str)
assert name in LvProvider.last_names

# Females last name.
name = self.fake.last_name_female()
assert name
self.assertIsInstance(name, str)
assert name in LvProvider.last_names_female + LvProvider.last_names_unisex

# Females only last name.
name = self.fake.last_name_unique_to_female()
assert name
self.assertIsInstance(name, str)
assert name in LvProvider.last_names_female

# Male last name.
name = self.fake.last_name_male()
assert name
self.assertIsInstance(name, str)
assert name in LvProvider.last_names_male + LvProvider.last_names_unisex

# Male only last name.
name = self.fake.last_name_unique_to_male()
assert name
self.assertIsInstance(name, str)
assert name in LvProvider.last_names_male


class TestNeNP(unittest.TestCase):
def setUp(self):
self.fake = Faker("ne_NP")
Expand Down

0 comments on commit ec1832f

Please sign in to comment.