本文整理汇总了Python中faker.providers.date_time.Provider.ssn方法的典型用法代码示例。如果您正苦于以下问题:Python Provider.ssn方法的具体用法?Python Provider.ssn怎么用?Python Provider.ssn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类faker.providers.date_time.Provider
的用法示例。
在下文中一共展示了Provider.ssn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_nl_BE_ssn_valid
# 需要导入模块: from faker.providers.date_time import Provider [as 别名]
# 或者: from faker.providers.date_time.Provider import ssn [as 别名]
def test_nl_BE_ssn_valid(self):
from faker.providers.ssn.nl_BE import Provider
provider = Provider(None)
for i in range (1000):
ssn = provider.ssn()
self.assertEqual(len(ssn), 11)
gen_ssn_base = ssn[0:6]
gen_seq = ssn[6:9]
gen_chksum = ssn[9:11]
gen_ssn_base_as_int = int(gen_ssn_base)
gen_seq_as_int = int(gen_seq)
gen_chksum_as_int = int(gen_chksum)
# Check that the sequence nr is between 1 inclusive and 998 inclusive
self.assertGreater(gen_seq_as_int,0)
self.assertLessEqual(gen_seq_as_int, 998)
# validate checksum calculation
# Since the century is not part of ssn, try both below and above year 2000
ssn_below = int(ssn[0:9])
chksum_below = 97 - (ssn_below % 97)
ssn_above = ssn_below + 2000000000
chksum_above = 97 - (ssn_above % 97)
results = [ chksum_above, chksum_below ]
self.assertIn(gen_chksum_as_int,results)
示例2: test_us_ssn_valid
# 需要导入模块: from faker.providers.date_time import Provider [as 别名]
# 或者: from faker.providers.date_time.Provider import ssn [as 别名]
def test_us_ssn_valid(self):
from faker.providers.ssn.en_US import Provider
provider = Provider(None)
for i in range(1000):
ssn = provider.ssn()
self.assertEqual(len(ssn), 11)
self.assertNotEqual(ssn[0], '9')
self.assertNotEqual(ssn[0:3], '666')
self.assertNotEqual(ssn[0:3], '000')
self.assertNotEqual(ssn[4:6], '00')
self.assertNotEqual(ssn[7:11], '0000')