Skip to content

Commit

Permalink
Added banks for en-IN (#1724)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiragMangukia authored Nov 4, 2022
1 parent 582a994 commit 589a4bb
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
49 changes: 49 additions & 0 deletions faker/providers/bank/en_IN/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from typing import Optional

from .. import Provider as BankProvider


class Provider(BankProvider):
"""Implement bank provider for ``en_IN`` locale.
Source: https://en.wikipedia.org/wiki/List_of_banks_in_India
"""

banks = (
"Bank of Baroda",
"Bank of India",
"Bank of Maharashtra",
"Canara Bank",
"Central Bank of India",
"Indian Bank",
"Indian Overseas Bank",
"Punjab National Bank",
"Punjab and Sind Bank",
"Union Bank of India",
"UCO Bank",
"State Bank of India",
"Axis Bank",
"Bandhan Bank",
"CSB Bank",
"City Union Bank",
"DCB Bank",
"Dhanlaxmi Bank",
"Federal Bank",
"HDFC Bank",
"ICICI Bank",
"IDBI Bank",
"IDFC First Bank",
"IndusInd Bank",
"Jammu & Kashmir Bank",
"Karnataka Bank",
"Karur Vysya Bank",
"Kotak Mahindra Bank",
"Nainital Bank",
"RBL Bank",
"South Indian Bank",
"Tamilnad Mercantile Bank",
"Yes Bank",
)

def bank(self, min_length: Optional[int] = None, max_length: Optional[int] = None) -> str:
"""Generate a bank name."""
return self.random_element(self.banks, min_length, max_length)
8 changes: 8 additions & 0 deletions tests/providers/test_bank.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,3 +370,11 @@ def test_iban(self, faker, num_samples):
assert is_valid_iban(iban)
assert iban[:2] == ElGrBankProvider.country_code
assert re.fullmatch(r"\d{2}\d{23}", iban[2:])


class TestEnIn:
"""Test en_IN bank provider"""

def test_bank(self, faker, num_samples):
for _ in range(num_samples):
assert re.match(r"\D{7,25}", faker.bank())

0 comments on commit 589a4bb

Please sign in to comment.