mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
asyncio: Fix getaddrinfo to accept service names (for port)
Patch by A. Jesse Jiryu Davis
This commit is contained in:
parent
a8f895f051
commit
a714616d36
2 changed files with 39 additions and 3 deletions
|
@ -146,6 +146,26 @@ class BaseEventTests(test_utils.TestCase):
|
|||
(INET, STREAM, TCP, '', ('1.2.3.4', 1)),
|
||||
base_events._ipaddr_info('1.2.3.4', b'1', INET, STREAM, TCP))
|
||||
|
||||
def test_getaddrinfo_servname(self):
|
||||
INET = socket.AF_INET
|
||||
STREAM = socket.SOCK_STREAM
|
||||
TCP = socket.IPPROTO_TCP
|
||||
|
||||
self.assertEqual(
|
||||
(INET, STREAM, TCP, '', ('1.2.3.4', 80)),
|
||||
base_events._ipaddr_info('1.2.3.4', 'http', INET, STREAM, TCP))
|
||||
|
||||
self.assertEqual(
|
||||
(INET, STREAM, TCP, '', ('1.2.3.4', 80)),
|
||||
base_events._ipaddr_info('1.2.3.4', b'http', INET, STREAM, TCP))
|
||||
|
||||
# Raises "service/proto not found".
|
||||
with self.assertRaises(OSError):
|
||||
base_events._ipaddr_info('1.2.3.4', 'nonsense', INET, STREAM, TCP)
|
||||
|
||||
with self.assertRaises(OSError):
|
||||
base_events._ipaddr_info('1.2.3.4', 'nonsense', INET, STREAM, TCP)
|
||||
|
||||
@patch_socket
|
||||
def test_ipaddr_info_no_inet_pton(self, m_socket):
|
||||
del m_socket.inet_pton
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue