diff options
author | Yury Selivanov <yselivanov@sprymix.com> | 2015-12-17 00:51:19 (GMT) |
---|---|---|
committer | Yury Selivanov <yselivanov@sprymix.com> | 2015-12-17 00:51:19 (GMT) |
commit | bcf8afd01522f70cea31334f09553c949a5b1592 (patch) | |
tree | 113706ef228a60fa9c04c4db8f239c43910c2b49 /Lib/test/test_asyncio | |
parent | e277a3dc5159b2ad61e57fa77bff485328864cc5 (diff) | |
parent | 5f68ca66bf02c2bdd8dabb98041f62737862eb07 (diff) | |
download | cpython-bcf8afd01522f70cea31334f09553c949a5b1592.zip cpython-bcf8afd01522f70cea31334f09553c949a5b1592.tar.gz cpython-bcf8afd01522f70cea31334f09553c949a5b1592.tar.bz2 |
Merge 3.4
Diffstat (limited to 'Lib/test/test_asyncio')
-rw-r--r-- | Lib/test/test_asyncio/test_base_events.py | 18 | ||||
-rw-r--r-- | Lib/test/test_asyncio/test_streams.py | 13 |
2 files changed, 18 insertions, 13 deletions
diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py index a46ac16..0166660 100644 --- a/Lib/test/test_asyncio/test_base_events.py +++ b/Lib/test/test_asyncio/test_base_events.py @@ -127,23 +127,27 @@ class BaseEventTests(test_utils.TestCase): def test_check_resolved_address(self): sock = socket.socket(socket.AF_INET) - base_events._check_resolved_address(sock, ('1.2.3.4', 1)) + with sock: + base_events._check_resolved_address(sock, ('1.2.3.4', 1)) sock = socket.socket(socket.AF_INET6) - base_events._check_resolved_address(sock, ('::3', 1)) - base_events._check_resolved_address(sock, ('::3%lo0', 1)) - self.assertRaises(ValueError, - base_events._check_resolved_address, sock, ('foo', 1)) + with sock: + base_events._check_resolved_address(sock, ('::3', 1)) + base_events._check_resolved_address(sock, ('::3%lo0', 1)) + with self.assertRaises(ValueError): + base_events._check_resolved_address(sock, ('foo', 1)) def test_check_resolved_sock_type(self): # Ensure we ignore extra flags in sock.type. if hasattr(socket, 'SOCK_NONBLOCK'): sock = socket.socket(type=socket.SOCK_STREAM | socket.SOCK_NONBLOCK) - base_events._check_resolved_address(sock, ('1.2.3.4', 1)) + with sock: + base_events._check_resolved_address(sock, ('1.2.3.4', 1)) if hasattr(socket, 'SOCK_CLOEXEC'): sock = socket.socket(type=socket.SOCK_STREAM | socket.SOCK_CLOEXEC) - base_events._check_resolved_address(sock, ('1.2.3.4', 1)) + with sock: + base_events._check_resolved_address(sock, ('1.2.3.4', 1)) class BaseEventLoopTests(test_utils.TestCase): diff --git a/Lib/test/test_asyncio/test_streams.py b/Lib/test/test_asyncio/test_streams.py index 0a9762d..3b115b1 100644 --- a/Lib/test/test_asyncio/test_streams.py +++ b/Lib/test/test_asyncio/test_streams.py @@ -647,12 +647,13 @@ os.close(fd) def server(): # Runs in a separate thread. sock = socket.socket() - sock.bind(('localhost', 0)) - sock.listen(1) - addr = sock.getsockname() - q.put(addr) - clt, _ = sock.accept() - clt.close() + with sock: + sock.bind(('localhost', 0)) + sock.listen(1) + addr = sock.getsockname() + q.put(addr) + clt, _ = sock.accept() + clt.close() @asyncio.coroutine def client(host, port): |