本文整理匯總了Python中faker.providers.misc.Provider.binary方法的典型用法代碼示例。如果您正苦於以下問題:Python Provider.binary方法的具體用法?Python Provider.binary怎麽用?Python Provider.binary使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類faker.providers.misc.Provider
的用法示例。
在下文中一共展示了Provider.binary方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_binary
# 需要導入模塊: from faker.providers.misc import Provider [as 別名]
# 或者: from faker.providers.misc.Provider import binary [as 別名]
def test_binary(self):
from faker.providers.misc import Provider
for _ in range(999):
length = random.randint(0, 2 ** 10)
binary = Provider.binary(length)
self.assertTrue(isinstance(binary, (bytes, bytearray)))
self.assertTrue(len(binary) == length)
for _ in range(999):
self.generator.seed(_)
binary1 = Provider.binary(_)
self.generator.seed(_)
binary2 = Provider.binary(_)
self.assertTrue(binary1 == binary2)
示例2: test_binary
# 需要導入模塊: from faker.providers.misc import Provider [as 別名]
# 或者: from faker.providers.misc.Provider import binary [as 別名]
def test_binary(self):
from faker.providers.misc import Provider
provider = Provider(self.generator)
for _ in range(999):
length = random.randint(0, 2 ** 10)
binary = provider.binary(length)
assert isinstance(binary, (bytes, bytearray))
assert len(binary) == length
for _ in range(999):
self.generator.seed(_)
binary1 = provider.binary(_)
self.generator.seed(_)
binary2 = provider.binary(_)
assert binary1 == binary2