Merge 3.4

This commit is contained in:
Yury Selivanov 2015-12-16 19:51:19 -05:00
commit bcf8afd015
2 changed files with 18 additions and 13 deletions

View File

@ -127,22 +127,26 @@ class BaseEventTests(test_utils.TestCase):
def test_check_resolved_address(self):
sock = socket.socket(socket.AF_INET)
with sock:
base_events._check_resolved_address(sock, ('1.2.3.4', 1))
sock = socket.socket(socket.AF_INET6)
with sock:
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 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)
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)
with sock:
base_events._check_resolved_address(sock, ('1.2.3.4', 1))

View File

@ -647,6 +647,7 @@ os.close(fd)
def server():
# Runs in a separate thread.
sock = socket.socket()
with sock:
sock.bind(('localhost', 0))
sock.listen(1)
addr = sock.getsockname()