Skip to content

Commit

Permalink
Add zh_CN bank locale (#1861)
Browse files Browse the repository at this point in the history
  • Loading branch information
nehCG committed May 16, 2023
1 parent 13344ed commit edc7975
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
37 changes: 37 additions & 0 deletions faker/providers/bank/zh_CN/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from .. import Provider as BankProvider


class Provider(BankProvider):
"""Implement bank provider for ``zh_CN`` locale.
Source: https://zh.wikipedia.org/wiki/中国大陆银行列表
"""

banks = (
"中国人民银行",
"国家开发银行",
"中国进出口银行",
"中国农业发展银行",
"交通银行",
"中国银行",
"中国建设银行",
"中国农业银行",
"中国工商银行",
"中国邮政储蓄银行",
"中国光大银行",
"中国民生银行",
"招商银行",
"中信银行",
"华夏银行",
"上海浦东发展银行",
"平安银行",
"广发银行",
"兴业银行",
"浙商银行",
"渤海银行",
"恒丰银行",
"西安银行",
)

def bank(self) -> str:
"""Generate a bank name."""
return self.random_element(self.banks)
8 changes: 8 additions & 0 deletions tests/providers/test_bank.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,3 +442,11 @@ def test_swift11_use_dataset(self, faker, num_samples):
assert code[4:6] == NlBeBankProvider.country_code
assert code[6:8] in NlBeBankProvider.swift_location_codes
assert code[8:11] in NlBeBankProvider.swift_branch_codes


class TestZhCn:
"""Test zh_CN bank provider"""

def test_bank(self, faker, num_samples):
for _ in range(num_samples):
assert re.match(r"[\u4e00-\u9fa5]{2,20}", faker.bank())

0 comments on commit edc7975

Please sign in to comment.