Skip to content

Commit 18dc11d

Browse files
committed
Test also MSG_TRUNC | MSG_PEEK
1 parent 11cb4cb commit 18dc11d

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

‎Lib/test/test_socket.py‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3321,6 +3321,19 @@ def _testRecvTrunc(self):
33213321
self.cli.sendto(MSG, 0, (HOST, self.port))
33223322
self.cli.sendto(MSG2, 0, (HOST, self.port))
33233323

3324+
@requireAttrs(socket, "MSG_TRUNC")
3325+
@requireAttrs(socket, "MSG_PEEK")
3326+
@unittest.skipIf(sys.platform == "win32", "Windows raises WSAEMSGSIZE")
3327+
def testRecvTruncPeek(self):
3328+
msg = self.serv.recv(len(MSG) - 5, socket.MSG_TRUNC | socket.MSG_PEEK)
3329+
self.assertEqual(msg, MSG[:-5])
3330+
3331+
msg = self.serv.recv(len(MSG))
3332+
self.assertEqual(msg, MSG)
3333+
3334+
def _testRecvTruncPeek(self):
3335+
self.cli.sendto(MSG, 0, (HOST, self.port))
3336+
33243337
@requireAttrs(socket, "MSG_TRUNC")
33253338
@unittest.skipIf(sys.platform == "win32", "Windows raises WSAEMSGSIZE")
33263339
def testRecvFromTrunc(self):
@@ -3336,6 +3349,20 @@ def _testRecvFromTrunc(self):
33363349
self.cli.sendto(MSG, 0, (HOST, self.port))
33373350
self.cli.sendto(MSG2, 0, (HOST, self.port))
33383351

3352+
@requireAttrs(socket, "MSG_TRUNC")
3353+
@requireAttrs(socket, "MSG_PEEK")
3354+
@unittest.skipIf(sys.platform == "win32", "Windows raises WSAEMSGSIZE")
3355+
def testRecvFromTruncPeek(self):
3356+
msg, addr = self.serv.recvfrom(len(MSG) - 5,
3357+
socket.MSG_TRUNC | socket.MSG_PEEK)
3358+
self.assertEqual(msg, MSG[:-5])
3359+
3360+
msg, addr = self.serv.recvfrom(len(MSG))
3361+
self.assertEqual(msg, MSG)
3362+
3363+
def _testRecvFromTruncPeek(self):
3364+
self.cli.sendto(MSG, 0, (HOST, self.port))
3365+
33393366

33403367
@unittest.skipUnless(HAVE_SOCKET_UDPLITE,
33413368
'UDPLITE sockets required for this test.')

0 commit comments

Comments
 (0)