summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio
diff options
context:
space:
mode:
authorAndrew Svetlov <andrew.svetlov@gmail.com>2018-12-03 19:08:13 (GMT)
committerGitHub <noreply@github.com>2018-12-03 19:08:13 (GMT)
commit3bc0ebab17bf5a2c29d2214743c82034f82e6573 (patch)
tree4dd0d06eb85963408b9d811b19d07116a51a70c7 /Lib/test/test_asyncio
parent3bb150d8148e3cc08418077a58f43e064b9fde61 (diff)
downloadcpython-3bc0ebab17bf5a2c29d2214743c82034f82e6573.zip
cpython-3bc0ebab17bf5a2c29d2214743c82034f82e6573.tar.gz
cpython-3bc0ebab17bf5a2c29d2214743c82034f82e6573.tar.bz2
bpo-35380: Enable TCP_NODELAY for proactor event loop (#10867)
Diffstat (limited to 'Lib/test/test_asyncio')
-rw-r--r--Lib/test/test_asyncio/test_base_events.py30
-rw-r--r--Lib/test/test_asyncio/test_selector_events.py26
2 files changed, 27 insertions, 29 deletions
diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py
index 6d544d1..5385475 100644
--- a/Lib/test/test_asyncio/test_base_events.py
+++ b/Lib/test/test_asyncio/test_base_events.py
@@ -2,7 +2,6 @@
import concurrent.futures
import errno
-import logging
import math
import os
import socket
@@ -15,7 +14,6 @@ from unittest import mock
import asyncio
from asyncio import base_events
from asyncio import constants
-from asyncio import events
from test.test_asyncio import utils as test_utils
from test import support
from test.support.script_helper import assert_python_ok
@@ -288,7 +286,7 @@ class BaseEventLoopTests(test_utils.TestCase):
loop.set_debug(debug)
if debug:
msg = ("Non-thread-safe operation invoked on an event loop other "
- "than the current one")
+ "than the current one")
with self.assertRaisesRegex(RuntimeError, msg):
loop.call_soon(cb)
with self.assertRaisesRegex(RuntimeError, msg):
@@ -2075,5 +2073,31 @@ class BaseLoopSockSendfileTests(test_utils.TestCase):
self.run_loop(self.loop.sock_sendfile(sock, self.file, -1))
+class TestSelectorUtils(test_utils.TestCase):
+ def check_set_nodelay(self, sock):
+ opt = sock.getsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY)
+ self.assertFalse(opt)
+
+ base_events._set_nodelay(sock)
+
+ opt = sock.getsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY)
+ self.assertTrue(opt)
+
+ @unittest.skipUnless(hasattr(socket, 'TCP_NODELAY'),
+ 'need socket.TCP_NODELAY')
+ def test_set_nodelay(self):
+ sock = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM,
+ proto=socket.IPPROTO_TCP)
+ with sock:
+ self.check_set_nodelay(sock)
+
+ sock = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM,
+ proto=socket.IPPROTO_TCP)
+ with sock:
+ sock.setblocking(False)
+ self.check_set_nodelay(sock)
+
+
+
if __name__ == '__main__':
unittest.main()
diff --git a/Lib/test/test_asyncio/test_selector_events.py b/Lib/test/test_asyncio/test_selector_events.py
index b99e8e6..d0d171a 100644
--- a/Lib/test/test_asyncio/test_selector_events.py
+++ b/Lib/test/test_asyncio/test_selector_events.py
@@ -14,7 +14,6 @@ from asyncio.selector_events import BaseSelectorEventLoop
from asyncio.selector_events import _SelectorTransport
from asyncio.selector_events import _SelectorSocketTransport
from asyncio.selector_events import _SelectorDatagramTransport
-from asyncio.selector_events import _set_nodelay
from test.test_asyncio import utils as test_utils
@@ -1344,30 +1343,5 @@ class SelectorDatagramTransportTests(test_utils.TestCase):
exc_info=(ConnectionRefusedError, MOCK_ANY, MOCK_ANY))
-class TestSelectorUtils(test_utils.TestCase):
- def check_set_nodelay(self, sock):
- opt = sock.getsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY)
- self.assertFalse(opt)
-
- _set_nodelay(sock)
-
- opt = sock.getsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY)
- self.assertTrue(opt)
-
- @unittest.skipUnless(hasattr(socket, 'TCP_NODELAY'),
- 'need socket.TCP_NODELAY')
- def test_set_nodelay(self):
- sock = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM,
- proto=socket.IPPROTO_TCP)
- with sock:
- self.check_set_nodelay(sock)
-
- sock = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM,
- proto=socket.IPPROTO_TCP)
- with sock:
- sock.setblocking(False)
- self.check_set_nodelay(sock)
-
-
if __name__ == '__main__':
unittest.main()