diff options
author | Yury Selivanov <yselivanov@sprymix.com> | 2015-12-17 01:23:47 (GMT) |
---|---|---|
committer | Yury Selivanov <yselivanov@sprymix.com> | 2015-12-17 01:23:47 (GMT) |
commit | 29832bb19d29ccb94b0b46d6a9d5ac662a41298d (patch) | |
tree | 0a74ca89f5d5bc069b3a99a2e8534f0a41169d08 /Lib | |
parent | 9f79a705abf891224678979178614a44ac071855 (diff) | |
parent | 152c408ed66ee0b15b7a5a9399e67f2d182b1585 (diff) | |
download | cpython-29832bb19d29ccb94b0b46d6a9d5ac662a41298d.zip cpython-29832bb19d29ccb94b0b46d6a9d5ac662a41298d.tar.gz cpython-29832bb19d29ccb94b0b46d6a9d5ac662a41298d.tar.bz2 |
Merge 3.5
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_asyncio/test_base_events.py | 47 |
1 files changed, 29 insertions, 18 deletions
diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py index 0166660..d660717 100644 --- a/Lib/test/test_asyncio/test_base_events.py +++ b/Lib/test/test_asyncio/test_base_events.py @@ -1157,21 +1157,28 @@ class BaseEventLoopWithSelectorTests(test_utils.TestCase): self.loop.add_writer = mock.Mock() self.loop.add_writer._is_coroutine = False - coro = self.loop.create_connection(MyProto, '1.2.3.4', 80) - self.loop.run_until_complete(coro) - sock.connect.assert_called_with(('1.2.3.4', 80)) - m_socket.socket.assert_called_with(family=m_socket.AF_INET, - proto=m_socket.IPPROTO_TCP, - type=m_socket.SOCK_STREAM) + coro = self.loop.create_connection(asyncio.Protocol, '1.2.3.4', 80) + t, p = self.loop.run_until_complete(coro) + try: + sock.connect.assert_called_with(('1.2.3.4', 80)) + m_socket.socket.assert_called_with(family=m_socket.AF_INET, + proto=m_socket.IPPROTO_TCP, + type=m_socket.SOCK_STREAM) + finally: + t.close() + test_utils.run_briefly(self.loop) # allow transport to close sock.family = socket.AF_INET6 - coro = self.loop.create_connection(MyProto, '::2', 80) - - self.loop.run_until_complete(coro) - sock.connect.assert_called_with(('::2', 80)) - m_socket.socket.assert_called_with(family=m_socket.AF_INET6, - proto=m_socket.IPPROTO_TCP, - type=m_socket.SOCK_STREAM) + coro = self.loop.create_connection(asyncio.Protocol, '::2', 80) + t, p = self.loop.run_until_complete(coro) + try: + sock.connect.assert_called_with(('::2', 80)) + m_socket.socket.assert_called_with(family=m_socket.AF_INET6, + proto=m_socket.IPPROTO_TCP, + type=m_socket.SOCK_STREAM) + finally: + t.close() + test_utils.run_briefly(self.loop) # allow transport to close @patch_socket def test_create_connection_ip_addr(self, m_socket): @@ -1559,11 +1566,15 @@ class BaseEventLoopWithSelectorTests(test_utils.TestCase): reuse_address=False, reuse_port=reuseport_supported) - self.loop.run_until_complete(coro) - bind.assert_called_with(('1.2.3.4', 0)) - m_socket.socket.assert_called_with(family=m_socket.AF_INET, - proto=m_socket.IPPROTO_UDP, - type=m_socket.SOCK_DGRAM) + t, p = self.loop.run_until_complete(coro) + try: + bind.assert_called_with(('1.2.3.4', 0)) + m_socket.socket.assert_called_with(family=m_socket.AF_INET, + proto=m_socket.IPPROTO_UDP, + type=m_socket.SOCK_DGRAM) + finally: + t.close() + test_utils.run_briefly(self.loop) # allow transport to close def test_accept_connection_retry(self): sock = mock.Mock() |