summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio/test_events.py
diff options
context:
space:
mode:
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>2022-12-28 04:37:55 (GMT)
committerGitHub <noreply@github.com>2022-12-28 04:37:55 (GMT)
commit5369bba8c594de7a643408550e19e1ff6df5178a (patch)
tree3bc6fa7a42c61ad5e4bbd91eb2d242b3eaed42f3 /Lib/test/test_asyncio/test_events.py
parent3da71ff0f26516c433538b2bfc4db196e20e0d44 (diff)
downloadcpython-5369bba8c594de7a643408550e19e1ff6df5178a.zip
cpython-5369bba8c594de7a643408550e19e1ff6df5178a.tar.gz
cpython-5369bba8c594de7a643408550e19e1ff6df5178a.tar.bz2
add tests for `asyncio` transport sockets (#100263)
Diffstat (limited to 'Lib/test/test_asyncio/test_events.py')
-rw-r--r--Lib/test/test_asyncio/test_events.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py
index 153b2de..e7771ed 100644
--- a/Lib/test/test_asyncio/test_events.py
+++ b/Lib/test/test_asyncio/test_events.py
@@ -823,6 +823,29 @@ class EventLoopTestsMixin:
# 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)