本文整理汇总了Python中faker.providers.misc.Provider.ipv4_private方法的典型用法代码示例。如果您正苦于以下问题:Python Provider.ipv4_private方法的具体用法?Python Provider.ipv4_private怎么用?Python Provider.ipv4_private使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类faker.providers.misc.Provider
的用法示例。
在下文中一共展示了Provider.ipv4_private方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ipv4_private
# 需要导入模块: from faker.providers.misc import Provider [as 别名]
# 或者: from faker.providers.misc.Provider import ipv4_private [as 别名]
def test_ipv4_private(self):
from faker.providers.internet import Provider
provider = Provider(self.generator)
for _ in range(99):
address = provider.ipv4_private()
address = six.text_type(address)
assert len(address) >= 7
assert len(address) <= 15
assert ip_address(address).is_private
assert (
re.compile(r'^(\d{1,3}\.){3}\d{1,3}$').search(address))
for _ in range(99):
address = provider.ipv4_private(network=True)
address = six.text_type(address)
assert len(address) >= 9
assert len(address) <= 18
assert ip_network(address)[0].is_private
assert (
re.compile(r'^(\d{1,3}\.){3}\d{1,3}/\d{1,2}$').search(address))
示例2: test_ipv4_private_class_c
# 需要导入模块: from faker.providers.misc import Provider [as 别名]
# 或者: from faker.providers.misc.Provider import ipv4_private [as 别名]
def test_ipv4_private_class_c(self):
from faker.providers.internet import Provider, _IPv4Constants
provider = Provider(self.generator)
class_network = _IPv4Constants._network_classes['c']
class_min = class_network.network_address
class_max = class_network.broadcast_address
for _ in range(99):
address = provider.ipv4_private(address_class='c')
address = six.text_type(address)
assert len(address) >= 7
assert len(address) <= 15
assert ip_address(address).is_private
assert ip_address(address) >= class_min
assert ip_address(address) <= class_max