@@ -272,7 +272,7 @@ def cb():
272272 loop .set_debug (debug )
273273 if debug :
274274 msg = ("Non-thread-safe operation invoked on an event loop other "
275- "than the current one" )
275+ "than the current one" )
276276 with self .assertRaisesRegex (RuntimeError , msg ):
277277 loop .call_soon (cb )
278278 with self .assertRaisesRegex (RuntimeError , msg ):
@@ -2056,5 +2056,31 @@ def test_negative_offset(self):
20562056 self .run_loop (self .loop .sock_sendfile (sock , self .file , - 1 ))
20572057
20582058
2059+ class TestSelectorUtils (test_utils .TestCase ):
2060+ def check_set_nodelay (self , sock ):
2061+ opt = sock .getsockopt (socket .IPPROTO_TCP , socket .TCP_NODELAY )
2062+ self .assertFalse (opt )
2063+
2064+ base_events ._set_nodelay (sock )
2065+
2066+ opt = sock .getsockopt (socket .IPPROTO_TCP , socket .TCP_NODELAY )
2067+ self .assertTrue (opt )
2068+
2069+ @unittest .skipUnless (hasattr (socket , 'TCP_NODELAY' ),
2070+ 'need socket.TCP_NODELAY' )
2071+ def test_set_nodelay (self ):
2072+ sock = socket .socket (family = socket .AF_INET , type = socket .SOCK_STREAM ,
2073+ proto = socket .IPPROTO_TCP )
2074+ with sock :
2075+ self .check_set_nodelay (sock )
2076+
2077+ sock = socket .socket (family = socket .AF_INET , type = socket .SOCK_STREAM ,
2078+ proto = socket .IPPROTO_TCP )
2079+ with sock :
2080+ sock .setblocking (False )
2081+ self .check_set_nodelay (sock )
2082+
2083+
2084+
20592085if __name__ == '__main__' :
20602086 unittest .main ()
0 commit comments