MCPcopy Index your code
hub / github.com/python/cpython / checkHopLimit

Method checkHopLimit

Lib/test/test_socket.py:4446–4472  ·  view source on GitHub ↗
(self, ancbufsize, maxhop=255, ignoreflags=0)

Source from the content-addressed store, hash-verified

4444 return d
4445
4446 def checkHopLimit(self, ancbufsize, maxhop=255, ignoreflags=0):
4447 # Receive hop limit into ancbufsize bytes of ancillary data
4448 # space. Check that data is MSG, ancillary data is not
4449 # truncated (but ignore any flags in ignoreflags), and hop
4450 # limit is between 0 and maxhop inclusive.
4451 self.serv_sock.setsockopt(socket.IPPROTO_IPV6,
4452 socket.IPV6_RECVHOPLIMIT, 1)
4453 self.misc_event.set()
4454 msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock,
4455 len(MSG), ancbufsize)
4456
4457 self.assertEqual(msg, MSG)
4458 self.checkRecvmsgAddress(addr, self.cli_addr)
4459 self.checkFlags(flags, eor=True, checkunset=socket.MSG_CTRUNC,
4460 ignore=ignoreflags)
4461
4462 self.assertEqual(len(ancdata), 1)
4463 self.assertIsInstance(ancdata[0], tuple)
4464 cmsg_level, cmsg_type, cmsg_data = ancdata[0]
4465 self.assertEqual(cmsg_level, socket.IPPROTO_IPV6)
4466 self.assertEqual(cmsg_type, socket.IPV6_HOPLIMIT)
4467 self.assertIsInstance(cmsg_data, bytes)
4468 self.assertEqual(len(cmsg_data), SIZEOF_INT)
4469 a = array.array("i")
4470 a.frombytes(cmsg_data)
4471 self.assertGreaterEqual(a[0], 0)
4472 self.assertLessEqual(a[0], maxhop)
4473
4474 @requireAttrs(socket, "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT")
4475 def testRecvHopLimit(self):

Callers 3

testRecvHopLimitMethod · 0.95
testSetHopLimitMethod · 0.95

Calls 9

checkFlagsMethod · 0.80
assertIsInstanceMethod · 0.80
assertGreaterEqualMethod · 0.80
assertLessEqualMethod · 0.80
setsockoptMethod · 0.45
setMethod · 0.45
doRecvmsgMethod · 0.45
assertEqualMethod · 0.45
checkRecvmsgAddressMethod · 0.45

Tested by

no test coverage detected