本文整理汇总了Python中seecr.test.portnumbergenerator.PortNumberGenerator.bind方法的典型用法代码示例。如果您正苦于以下问题:Python PortNumberGenerator.bind方法的具体用法?Python PortNumberGenerator.bind怎么用?Python PortNumberGenerator.bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类seecr.test.portnumbergenerator.PortNumberGenerator
的用法示例。
在下文中一共展示了PortNumberGenerator.bind方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testBindPortRangeNumberGiven
# 需要导入模块: from seecr.test.portnumbergenerator import PortNumberGenerator [as 别名]
# 或者: from seecr.test.portnumbergenerator.PortNumberGenerator import bind [as 别名]
def testBindPortRangeNumberGiven(self):
port = PortNumberGenerator.next(blockSize=2)
port2 = port + 1
PortNumberGenerator.bind(port=port, blockSize=2)
self.assertNotBound(bindV4(ip='127.0.0.1', port=port, protocol='tcp', reuse=True))
self.assertNotBound(bindV4(ip='127.0.0.1', port=port2, protocol='tcp', reuse=True))
PortNumberGenerator.unbind(port=port, blockSize=2)
self.assertBoundAndUnbind(bindV4(ip='127.0.0.1', port=port, protocol='tcp', reuse=True))
self.assertBoundAndUnbind(bindV4(ip='127.0.0.1', port=port2, protocol='tcp', reuse=True))
示例2: testBindPortNumberGiven
# 需要导入模块: from seecr.test.portnumbergenerator import PortNumberGenerator [as 别名]
# 或者: from seecr.test.portnumbergenerator.PortNumberGenerator import bind [as 别名]
def testBindPortNumberGiven(self):
port, close = attemptBinding(bindPort=0); close()
PortNumberGenerator.bind(port=port)
self.assertNotBound(bindV4(ip='127.0.0.1', port=port, protocol='tcp', reuse=True))
if has_dual_stack():
self.assertNotBound(bindV6(ip='::1', port=port, protocol='tcp', reuse=True))
PortNumberGenerator.unbind(port=port)
self.assertBoundAndUnbind(bindV4(ip='127.0.0.1', port=port, protocol='tcp', reuse=True))
if has_dual_stack():
self.assertBoundAndUnbind(bindV6(ip='::1', port=port, protocol='tcp', reuse=True))
示例3: testBindPortNumberGivenKeepsOldUsedPortsOnFailure
# 需要导入模块: from seecr.test.portnumbergenerator import PortNumberGenerator [as 别名]
# 或者: from seecr.test.portnumbergenerator.PortNumberGenerator import bind [as 别名]
def testBindPortNumberGivenKeepsOldUsedPortsOnFailure(self):
port1 = PortNumberGenerator.next()
port2 = PortNumberGenerator.next(blockSize=2)
port3 = port2 + 1
PortNumberGenerator.bind(port3)
# Overlap with already bind port: port3.
self.assertEquals(set([port1, port2, port3]), PortNumberGenerator._usedPorts)
self.assertEquals(set([port3]), set(PortNumberGenerator._bound.keys()))
try:
PortNumberGenerator.bind(port2, blockSize=2)
except RuntimeError, e:
self.assertEquals('Port(s) already bound', str(e))
示例4: testBindPortNumberGivenIgnoresUsedPorts
# 需要导入模块: from seecr.test.portnumbergenerator import PortNumberGenerator [as 别名]
# 或者: from seecr.test.portnumbergenerator.PortNumberGenerator import bind [as 别名]
def testBindPortNumberGivenIgnoresUsedPorts(self):
port = PortNumberGenerator.next()
PortNumberGenerator.bind(port)
self.assertNotBound(bindV4(ip='127.0.0.1', port=port, protocol='tcp', reuse=True))