本文整理汇总了Python中faker.providers.misc.Provider.pystr方法的典型用法代码示例。如果您正苦于以下问题:Python Provider.pystr方法的具体用法?Python Provider.pystr怎么用?Python Provider.pystr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类faker.providers.misc.Provider
的用法示例。
在下文中一共展示了Provider.pystr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_random_pystr_characters
# 需要导入模块: from faker.providers.misc import Provider [as 别名]
# 或者: from faker.providers.misc.Provider import pystr [as 别名]
def test_random_pystr_characters(self):
from faker.providers.python import Provider
provider = Provider(self.generator)
characters = provider.pystr()
self.assertEqual(len(characters), 20)
characters = provider.pystr(max_chars=255)
self.assertEqual(len(characters), 255)
characters = provider.pystr(max_chars=0)
self.assertEqual(characters, '')
characters = provider.pystr(max_chars=-10)
self.assertEqual(characters, '')
characters = provider.pystr(min_chars=10, max_chars=255)
self.assertTrue((len(characters) >= 10))
示例2: test_random_pystr_characters
# 需要导入模块: from faker.providers.misc import Provider [as 别名]
# 或者: from faker.providers.misc.Provider import pystr [as 别名]
def test_random_pystr_characters(self):
from faker.providers.python import Provider
provider = Provider(self.generator)
characters = provider.pystr()
assert len(characters) == 20
characters = provider.pystr(max_chars=255)
assert len(characters) == 255
characters = provider.pystr(max_chars=0)
assert characters == ''
characters = provider.pystr(max_chars=-10)
assert characters == ''
characters = provider.pystr(min_chars=10, max_chars=255)
assert (len(characters) >= 10)