summaryrefslogtreecommitdiff
path: root/Lib/test
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_asyncio/test_base_events.py30
-rw-r--r--Lib/test/test_asyncio/test_events.py1
-rw-r--r--Lib/test/test_asyncio/test_windows_events.py2
3 files changed, 21 insertions, 12 deletions
diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py
index 5c120ff17b..f093ed0c9b 100644
--- a/Lib/test/test_asyncio/test_base_events.py
+++ b/Lib/test/test_asyncio/test_base_events.py
@@ -446,34 +446,41 @@ class BaseEventLoopWithSelectorTests(unittest.TestCase):
def test_create_connection_server_hostname_default(self):
self.loop.getaddrinfo = unittest.mock.Mock()
+
def mock_getaddrinfo(*args, **kwds):
f = futures.Future(loop=self.loop)
f.set_result([(socket.AF_INET, socket.SOCK_STREAM,
socket.SOL_TCP, '', ('1.2.3.4', 80))])
return f
+
self.loop.getaddrinfo.side_effect = mock_getaddrinfo
self.loop.sock_connect = unittest.mock.Mock()
self.loop.sock_connect.return_value = ()
self.loop._make_ssl_transport = unittest.mock.Mock()
- def mock_make_ssl_transport(sock, protocol, sslcontext, waiter, **kwds):
+
+ def mock_make_ssl_transport(sock, protocol, sslcontext, waiter,
+ **kwds):
waiter.set_result(None)
+
self.loop._make_ssl_transport.side_effect = mock_make_ssl_transport
ANY = unittest.mock.ANY
# First try the default server_hostname.
self.loop._make_ssl_transport.reset_mock()
coro = self.loop.create_connection(MyProto, 'python.org', 80, ssl=True)
self.loop.run_until_complete(coro)
- self.loop._make_ssl_transport.assert_called_with(ANY, ANY, ANY, ANY,
- server_side=False,
- server_hostname='python.org')
+ self.loop._make_ssl_transport.assert_called_with(
+ ANY, ANY, ANY, ANY,
+ server_side=False,
+ server_hostname='python.org')
# Next try an explicit server_hostname.
self.loop._make_ssl_transport.reset_mock()
coro = self.loop.create_connection(MyProto, 'python.org', 80, ssl=True,
server_hostname='perl.com')
self.loop.run_until_complete(coro)
- self.loop._make_ssl_transport.assert_called_with(ANY, ANY, ANY, ANY,
- server_side=False,
- server_hostname='perl.com')
+ self.loop._make_ssl_transport.assert_called_with(
+ ANY, ANY, ANY, ANY,
+ server_side=False,
+ server_hostname='perl.com')
# Finally try an explicit empty server_hostname.
self.loop._make_ssl_transport.reset_mock()
coro = self.loop.create_connection(MyProto, 'python.org', 80, ssl=True,
@@ -485,9 +492,11 @@ class BaseEventLoopWithSelectorTests(unittest.TestCase):
def test_create_connection_server_hostname_errors(self):
# When not using ssl, server_hostname must be None (but '' is OK).
- coro = self.loop.create_connection(MyProto, 'python.org', 80, server_hostname='')
+ coro = self.loop.create_connection(MyProto, 'python.org', 80,
+ server_hostname='')
self.assertRaises(ValueError, self.loop.run_until_complete, coro)
- coro = self.loop.create_connection(MyProto, 'python.org', 80, server_hostname='python.org')
+ coro = self.loop.create_connection(MyProto, 'python.org', 80,
+ server_hostname='python.org')
self.assertRaises(ValueError, self.loop.run_until_complete, coro)
# When using ssl, server_hostname may be None if host is non-empty.
@@ -495,7 +504,8 @@ class BaseEventLoopWithSelectorTests(unittest.TestCase):
self.assertRaises(ValueError, self.loop.run_until_complete, coro)
coro = self.loop.create_connection(MyProto, None, 80, ssl=True)
self.assertRaises(ValueError, self.loop.run_until_complete, coro)
- coro = self.loop.create_connection(MyProto, None, None, ssl=True, sock=socket.socket())
+ coro = self.loop.create_connection(MyProto, None, None,
+ ssl=True, sock=socket.socket())
self.assertRaises(ValueError, self.loop.run_until_complete, coro)
def test_create_server_empty_host(self):
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py
index 83d73973de..1288941996 100644
--- a/Lib/test/test_asyncio/test_events.py
+++ b/Lib/test/test_asyncio/test_events.py
@@ -1276,7 +1276,6 @@ if sys.platform == 'win32':
def create_event_loop(self):
return windows_events.SelectorEventLoop()
-
class ProactorEventLoopTests(EventLoopTestsMixin,
SubprocessTestsMixin,
unittest.TestCase):
diff --git a/Lib/test/test_asyncio/test_windows_events.py b/Lib/test/test_asyncio/test_windows_events.py
index 553ea34345..f5147de25d 100644
--- a/Lib/test/test_asyncio/test_windows_events.py
+++ b/Lib/test/test_asyncio/test_windows_events.py
@@ -77,7 +77,7 @@ class ProactorTests(unittest.TestCase):
stream_reader = streams.StreamReader(loop=self.loop)
protocol = streams.StreamReaderProtocol(stream_reader)
trans, proto = yield from self.loop.create_pipe_connection(
- lambda:protocol, ADDRESS)
+ lambda: protocol, ADDRESS)
self.assertIsInstance(trans, transports.Transport)
self.assertEqual(protocol, proto)
clients.append((stream_reader, trans))