summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio/test_windows_utils.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-06-03 22:12:28 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-06-03 22:12:28 (GMT)
commita9fa2664ab98a1077e5b16d66c17aea0cd631ed7 (patch)
tree6a7b983b052c0faeaccd9dedc2d644959aadd6fc /Lib/test/test_asyncio/test_windows_utils.py
parent223a624158254e2c907116a756f6ffe63c49fb7a (diff)
downloadcpython-a9fa2664ab98a1077e5b16d66c17aea0cd631ed7.zip
cpython-a9fa2664ab98a1077e5b16d66c17aea0cd631ed7.tar.gz
cpython-a9fa2664ab98a1077e5b16d66c17aea0cd631ed7.tar.bz2
Issue #21119: asyncio: Make sure that socketpair() close sockets on error
Close the listening socket if sock.bind() raises an exception.
Diffstat (limited to 'Lib/test/test_asyncio/test_windows_utils.py')
-rw-r--r--Lib/test/test_asyncio/test_windows_utils.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_windows_utils.py b/Lib/test/test_asyncio/test_windows_utils.py
index 9daf434..b1f81da 100644
--- a/Lib/test/test_asyncio/test_windows_utils.py
+++ b/Lib/test/test_asyncio/test_windows_utils.py
@@ -51,6 +51,15 @@ class WinsocketpairTests(unittest.TestCase):
self.assertRaises(ValueError,
windows_utils.socketpair, proto=1)
+ @mock.patch('asyncio.windows_utils.socket')
+ def test_winsocketpair_close(self, m_socket):
+ m_socket.AF_INET = socket.AF_INET
+ m_socket.SOCK_STREAM = socket.SOCK_STREAM
+ sock = mock.Mock()
+ m_socket.socket.return_value = sock
+ sock.bind.side_effect = OSError
+ self.assertRaises(OSError, windows_utils.socketpair)
+ self.assertTrue(sock.close.called)
class PipeTests(unittest.TestCase):