test case fix (always sort result of `DNSUtils.textToIp`, because order of result from `socket.getaddrinfo` is undefined (system depended)

pull/1423/head
sebres 2016-05-13 21:44:07 +02:00
parent 3d3735706b
commit e0924e0d1b
1 changed files with 6 additions and 3 deletions

View File

@ -1357,9 +1357,11 @@ class DNSUtilsNetworkTests(unittest.TestCase):
res = DNSUtils.textToIp('www.example.com', 'no') res = DNSUtils.textToIp('www.example.com', 'no')
self.assertEqual(res, []) self.assertEqual(res, [])
res = DNSUtils.textToIp('www.example.com', 'warn') res = DNSUtils.textToIp('www.example.com', 'warn')
self.assertEqual(res, ['93.184.216.34', '2606:2800:220:1:248:1893:25c8:1946']) # sort ipaddr, IPv4 is always smaller as IPv6
self.assertEqual(sorted(res), ['93.184.216.34', '2606:2800:220:1:248:1893:25c8:1946'])
res = DNSUtils.textToIp('www.example.com', 'yes') res = DNSUtils.textToIp('www.example.com', 'yes')
self.assertEqual(res, ['93.184.216.34', '2606:2800:220:1:248:1893:25c8:1946']) # sort ipaddr, IPv4 is always smaller as IPv6
self.assertEqual(sorted(res), ['93.184.216.34', '2606:2800:220:1:248:1893:25c8:1946'])
def testTextToIp(self): def testTextToIp(self):
# Test hostnames # Test hostnames
@ -1371,7 +1373,8 @@ class DNSUtilsNetworkTests(unittest.TestCase):
for s in hostnames: for s in hostnames:
res = DNSUtils.textToIp(s, 'yes') res = DNSUtils.textToIp(s, 'yes')
if s == 'www.example.com': if s == 'www.example.com':
self.assertEqual(res, ['93.184.216.34', '2606:2800:220:1:248:1893:25c8:1946']) # sort ipaddr, IPv4 is always smaller as IPv6
self.assertEqual(sorted(res), ['93.184.216.34', '2606:2800:220:1:248:1893:25c8:1946'])
else: else:
self.assertEqual(res, []) self.assertEqual(res, [])