Skip to content

Commit

Permalink
Added person provider for gu_IN locale with tests (#2111)
Browse files Browse the repository at this point in the history
  • Loading branch information
debjeetsingha authored Oct 16, 2024
1 parent 871efdb commit 55ccb6f
Show file tree
Hide file tree
Showing 2 changed files with 220 additions and 0 deletions.
157 changes: 157 additions & 0 deletions faker/providers/person/gu_IN/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
from .. import Provider as PersonProvider


class Provider(PersonProvider):

formats_male = (
"{{first_name_male}} {{last_name}}",
"{{prefix_male}} {{first_name_male}} {{last_name}}",
)

formats_female = (
"{{first_name_female}} {{last_name}}",
"{{prefix_female}} {{first_name_female}} {{last_name}}",
)

formats = (
"{{first_name}} {{last_name}}",
"{{prefix}} {{first_name}} {{last_name}}",
)

# names taken from https://www.behindthename.com/names/gender/feminine/usage/gujarati
first_names_female = (
"અંકિતા",
"અવની",
"હીરા",
"કાજલ",
"કિરણ",
"નેહા",
"નિશા",
"પૂજા",
"પ્રાચી",
"પ્રીતિ",
"પ્રીતિ",
"પૂજા",
"રચના",
"રાધીકા",
"શ્રેયા",
"શ્વેતા",
"સોનલ",
"તન્વી",
"તેજલ",
"ઉર્વી",
"વર્ષા",
)

# names taken from https://www.behindthename.com/names/gender/masculine/usage/gujarati
first_names_male = (
"અભિષેક",
"અજય",
"અક્ષય",
"આનંદ",
"અનિલ",
"અંકિત",
"અર્જુન",
"અરુણ",
"આશિષ",
"અશોક",
"ભારત",
"બ્રિજેશ",
"ચેતન",
"ચિરાગ",
"દર્શન",
"દીપા",
"દીપક",
"ધવલ",
"દિલીપ",
"દિનેશ",
"દીપા",
"દીપક",
"હરીશ",
"હર્ષ",
"હર્ષલ",
"હીરા",
"જગદીશ",
"જય",
"જયેશ",
"જિતેન્દ્ર",
"કાજલ",
"કમલ",
"કરણ",
"કિરણ",
"કિશન",
"કૃષ્ણ",
"કુમાર",
"કુનાલ",
"મહેન્દ્ર",
"મહેશ",
"મનોજ",
"મયૂર",
"મિતુલ",
"મુકેશ",
"નરેન્દ્ર",
"નીરજ",
"નિખિલ",
"નીરજ",
"નીરવ",
"નિશાંત",
"નિતિન",
"પંકજ",
"પાર્થ",
"પ્રકાશ",
"પ્રણવ",
"પ્રતિક",
"પ્રતિક",
"પ્રવીણ",
"પ્રવીણ",
"રાહુલ",
"રાજ",
"રાજેન્દ્ર",
"રાજેશ",
"રાકેશ",
"રમેશ",
"રવિ",
"રોહિત",
"સચિન",
"સમીર",
"સમીર",
"સંદિપ",
"સંદિપ",
"સંજય",
"સંજીવ",
"સંજીવ",
"શેખર",
"સિદ્ધાર્થ",
"સુભાષ",
"સુનીલ",
"સૂરજ",
"તુષાર",
"વસંત",
"વિક્રમ",
"વિપુલ",
"વિરાજ",
"વિશાલ",
"વિવેક",
"યશ",
)

first_names = first_names_female + first_names_male

# last names taken from https://surnames.behindthename.com/names/usage/gujarati
last_names = (
"ચૌધરી",
"ચૌધરી",
"ગઢવી",
"ગુપ્તા",
"જૈન",
"જોષી",
"કુમાર",
"પટેલ",
"શર્મા",
)

prefixes_female = ("શ્રીમતી", "કુમારી")

prefixes_male = ("શ્રી", "શ્રીમન")

prefixes = prefixes_female + prefixes_male
63 changes: 63 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.fi_FI import Provider as FiProvider
from faker.providers.person.fr_BE import Provider as FrBEProvider
from faker.providers.person.ga_IE import Provider as GaIEProvider
from faker.providers.person.gu_IN import Provider as GuINProvider
from faker.providers.person.he_IL import Provider as HeILProvider
from faker.providers.person.hi_IN import Provider as HiINProvider
from faker.providers.person.hy_AM import Provider as HyAmProvider
Expand Down Expand Up @@ -673,6 +674,68 @@ def setUp(self):
Faker.seed(0)


class TestGuIN(unittest.TestCase):
"""Tests person in the gu_IN locale"""

def setUp(self):
self.fake = Faker("gu_IN")
Faker.seed(0)

"""Verify that gender specific names are set correctly"""

def test_first_name(self):
name = self.fake.first_name()
self.assertIsInstance(name, str)
assert name in GuINProvider.first_names

def test_first_name_male(self):
name = self.fake.first_name_male()
self.assertIsInstance(name, str)
assert name in GuINProvider.first_names_male

def test_first_name_female(self):
name = self.fake.first_name_female()
self.assertIsInstance(name, str)
assert name in GuINProvider.first_names_female

def test_last_name(self):
last_name = self.fake.last_name()
self.assertIsInstance(last_name, str)
assert last_name in GuINProvider.last_names

def test_name(self):
name = self.fake.name().split()
assert all(isinstance(n, str) for n in name)
if len(name) == 3:
assert all(
[
name[0] in GuINProvider.prefixes,
name[1] in GuINProvider.first_names,
name[2] in GuINProvider.last_names,
]
)
else:
assert name[0] in GuINProvider.first_names
assert name[-1] in GuINProvider.last_names

"""Verify that gender specific prefixes are set correctly"""

def test_prefix(self):
prefix = self.fake.prefix()
self.assertIsInstance(prefix, str)
assert prefix in GuINProvider.prefixes

def test_prefix_female(self):
prefix = self.fake.prefix_female()
self.assertIsInstance(prefix, str)
assert prefix in GuINProvider.prefixes_female

def test_prefix_male(self):
prefix = self.fake.prefix_male()
self.assertIsInstance(prefix, str)
assert prefix in GuINProvider.prefixes_male


class TestHeIL(unittest.TestCase):
"""Tests person in the he_IL locale."""

Expand Down

0 comments on commit 55ccb6f

Please sign in to comment.