[Python-checkins] add tests for `asyncio` transport sockets (#100263)
kumaraditya303
webhook-mailer at python.org
Tue Dec 27 23:38:01 EST 2022
https://github.com/python/cpython/commit/5369bba8c594de7a643408550e19e1ff6df5178a
commit: 5369bba8c594de7a643408550e19e1ff6df5178a
branch: main
author: Kumar Aditya <59607654+kumaraditya303 at users.noreply.github.com>
committer: kumaraditya303 <59607654+kumaraditya303 at users.noreply.github.com>
date: 2022-12-28T10:07:55+05:30
summary:
add tests for `asyncio` transport sockets (#100263)
files:
M Lib/test/test_asyncio/test_events.py
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py
index 153b2de81722..e7771edd2e4a 100644
--- a/Lib/test/test_asyncio/test_events.py
+++ b/Lib/test/test_asyncio/test_events.py
@@ -823,6 +823,29 @@ def test_create_server(self):
# close server
server.close()
+ def test_create_server_trsock(self):
+ proto = MyProto(self.loop)
+ f = self.loop.create_server(lambda: proto, '0.0.0.0', 0)
+ server = self.loop.run_until_complete(f)
+ self.assertEqual(len(server.sockets), 1)
+ sock = server.sockets[0]
+ self.assertIsInstance(sock, asyncio.trsock.TransportSocket)
+ host, port = sock.getsockname()
+ self.assertEqual(host, '0.0.0.0')
+ dup = sock.dup()
+ self.addCleanup(dup.close)
+ self.assertIsInstance(dup, socket.socket)
+ self.assertFalse(sock.get_inheritable())
+ with self.assertRaises(ValueError):
+ sock.settimeout(1)
+ sock.settimeout(0)
+ self.assertEqual(sock.gettimeout(), 0)
+ with self.assertRaises(ValueError):
+ sock.setblocking(True)
+ sock.setblocking(False)
+ server.close()
+
+
@unittest.skipUnless(hasattr(socket, 'SO_REUSEPORT'), 'No SO_REUSEPORT')
def test_create_server_reuse_port(self):
proto = MyProto(self.loop)
More information about the Python-checkins
mailing list