summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2016-06-02 20:51:07 (GMT)
committerYury Selivanov <yselivanov@sprymix.com>2016-06-02 20:51:07 (GMT)
commita714616d36131860f4f3f18bc2cfaf9a578db053 (patch)
treebb7461f019d61925f098861476baf4710d09e08f /Lib/test/test_asyncio
parenta8f895f051588cc5186650f13118b0149ae7e3d5 (diff)
downloadcpython-a714616d36131860f4f3f18bc2cfaf9a578db053.zip
cpython-a714616d36131860f4f3f18bc2cfaf9a578db053.tar.gz
cpython-a714616d36131860f4f3f18bc2cfaf9a578db053.tar.bz2
asyncio: Fix getaddrinfo to accept service names (for port)
Patch by A. Jesse Jiryu Davis
Diffstat (limited to 'Lib/test/test_asyncio')
-rw-r--r--Lib/test/test_asyncio/test_base_events.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py
index 81c35c8..e800ec4 100644
--- a/Lib/test/test_asyncio/test_base_events.py
+++ b/Lib/test/test_asyncio/test_base_events.py
@@ -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