本文整理匯總了Python中faker.providers.misc.Provider.password方法的典型用法代碼示例。如果您正苦於以下問題:Python Provider.password方法的具體用法?Python Provider.password怎麽用?Python Provider.password使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類faker.providers.misc.Provider
的用法示例。
在下文中一共展示了Provider.password方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_password
# 需要導入模塊: from faker.providers.misc import Provider [as 別名]
# 或者: from faker.providers.misc.Provider import password [as 別名]
def test_password(self):
from faker.providers.misc import Provider
def in_string(char, _str):
return char in _str
for _ in range(999):
password = Provider.password()
self.assertTrue(any([in_string(char, password) for char in "[email protected]#$%^&*()_+"]))
self.assertTrue(any([in_string(char, password) for char in string.digits]))
self.assertTrue(any([in_string(char, password) for char in string.ascii_uppercase]))
self.assertTrue(any([in_string(char, password) for char in string.ascii_lowercase]))
with self.assertRaises(AssertionError):
Provider.password(length=2)
示例2: test_password
# 需要導入模塊: from faker.providers.misc import Provider [as 別名]
# 或者: from faker.providers.misc.Provider import password [as 別名]
def test_password(self):
from faker.providers.misc import Provider
provider = Provider(self.generator)
def in_string(char, _str):
return char in _str
for _ in range(999):
password = provider.password()
assert any(in_string(char, password) for char in "[email protected]#$%^&*()_+")
assert any(in_string(char, password) for char in string.digits)
assert any(in_string(char, password) for char in string.ascii_uppercase)
assert any(in_string(char, password) for char in string.ascii_lowercase)
with pytest.raises(AssertionError):
provider.password(length=2)