本文整理汇总了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)