當前位置: 首頁>>代碼示例>>Python>>正文


Python Provider.ssn方法代碼示例

本文整理匯總了Python中faker.providers.misc.Provider.ssn方法的典型用法代碼示例。如果您正苦於以下問題:Python Provider.ssn方法的具體用法?Python Provider.ssn怎麽用?Python Provider.ssn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在faker.providers.misc.Provider的用法示例。


在下文中一共展示了Provider.ssn方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_nl_BE_ssn_valid

# 需要導入模塊: from faker.providers.misc import Provider [as 別名]
# 或者: from faker.providers.misc.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)
開發者ID:Stasonhub,項目名稱:faker-2,代碼行數:28,代碼來源:factory.py

示例2: test_us_ssn_valid

# 需要導入模塊: from faker.providers.misc import Provider [as 別名]
# 或者: from faker.providers.misc.Provider import ssn [as 別名]
    def test_us_ssn_valid(self):
        from faker.providers.ssn.en_US import Provider

        provider = Provider(self.generator)
        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')
開發者ID:bessl,項目名稱:faker-1,代碼行數:14,代碼來源:test_factory.py

示例3: test_us_ssn_valid

# 需要導入模塊: from faker.providers.misc import Provider [as 別名]
# 或者: from faker.providers.misc.Provider import ssn [as 別名]
    def test_us_ssn_valid(self):
        from faker.providers.ssn.en_US import Provider

        provider = Provider(self.generator)
        for i in range(1000):
            ssn = provider.ssn()
            assert len(ssn) == 11
            assert ssn[0] != '9'
            assert ssn[0:3] != '666'
            assert ssn[0:3] != '000'
            assert ssn[4:6] != '00'
            assert ssn[7:11] != '0000'
開發者ID:joke2k,項目名稱:faker,代碼行數:14,代碼來源:test_factory.py


注:本文中的faker.providers.misc.Provider.ssn方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。