Skip to content

Commit cee691a

Browse files
committed
more tests
1 parent 54043df commit cee691a

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Lib/test/test_ipaddress.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import ipaddress
1414
import weakref
1515
from test.support import LARGEST, SMALLEST
16-
from typing import Iterator
16+
from collections.abc import Iterator
1717

1818

1919
class BaseTestCase(unittest.TestCase):
@@ -1475,6 +1475,7 @@ def testGetSupernet4(self):
14751475
def testHosts(self):
14761476
hosts = self.ipv4_network.hosts()
14771477
self.assertIsInstance(hosts, Iterator)
1478+
self.assertIsNotNone(next(hosts))
14781479
hosts = list(self.ipv4_network.hosts())
14791480
self.assertEqual(254, len(hosts))
14801481
self.assertEqual(ipaddress.IPv4Address('1.2.3.1'), hosts[0])
@@ -1483,6 +1484,7 @@ def testHosts(self):
14831484
ipv6_network = ipaddress.IPv6Network('2001:658:22a:cafe::/120')
14841485
hosts = ipv6_network.hosts()
14851486
self.assertIsInstance(hosts, Iterator)
1487+
self.assertIsNotNone(next(hosts))
14861488
hosts = list(ipv6_network.hosts())
14871489
self.assertEqual(255, len(hosts))
14881490
self.assertEqual(ipaddress.IPv6Address('2001:658:22a:cafe::1'), hosts[0])
@@ -1510,6 +1512,10 @@ def testHosts(self):
15101512
tpl_args = ('1.2.3.4', 32)
15111513
self.assertIsInstance(ipaddress.ip_network(str_args).hosts(), Iterator)
15121514
self.assertIsInstance(ipaddress.ip_network(tpl_args).hosts(), Iterator)
1515+
hosts = ipaddress.ip_network(str_args).hosts()
1516+
self.assertIsNotNone(next(hosts))
1517+
hosts = ipaddress.ip_network(tpl_args).hosts()
1518+
self.assertIsNotNone(next(hosts))
15131519
self.assertEqual(addrs, list(ipaddress.ip_network(str_args).hosts()))
15141520
self.assertEqual(addrs, list(ipaddress.ip_network(tpl_args).hosts()))
15151521
self.assertEqual(list(ipaddress.ip_network(str_args).hosts()),
@@ -1521,6 +1527,10 @@ def testHosts(self):
15211527
tpl_args = ('2001:658:22a:cafe::', 127)
15221528
self.assertIsInstance(ipaddress.ip_network(str_args).hosts(), Iterator)
15231529
self.assertIsInstance(ipaddress.ip_network(tpl_args).hosts(), Iterator)
1530+
hosts = ipaddress.ip_network(str_args).hosts()
1531+
self.assertIsNotNone(next(hosts))
1532+
hosts = ipaddress.ip_network(tpl_args).hosts()
1533+
self.assertIsNotNone(next(hosts))
15241534
self.assertEqual(addrs, list(ipaddress.ip_network(str_args).hosts()))
15251535
self.assertEqual(addrs, list(ipaddress.ip_network(tpl_args).hosts()))
15261536
self.assertEqual(list(ipaddress.ip_network(str_args).hosts()),
@@ -1529,6 +1539,12 @@ def testHosts(self):
15291539
addrs = [ipaddress.IPv6Address('2001:658:22a:cafe::1'), ]
15301540
str_args = '2001:658:22a:cafe::1/128'
15311541
tpl_args = ('2001:658:22a:cafe::1', 128)
1542+
self.assertIsInstance(ipaddress.ip_network(str_args).hosts(), Iterator)
1543+
self.assertIsInstance(ipaddress.ip_network(tpl_args).hosts(), Iterator)
1544+
hosts = ipaddress.ip_network(str_args).hosts()
1545+
self.assertIsNotNone(next(hosts))
1546+
hosts = ipaddress.ip_network(tpl_args).hosts()
1547+
self.assertIsNotNone(next(hosts))
15321548
self.assertEqual(addrs, list(ipaddress.ip_network(str_args).hosts()))
15331549
self.assertEqual(addrs, list(ipaddress.ip_network(tpl_args).hosts()))
15341550
self.assertEqual(list(ipaddress.ip_network(str_args).hosts()),

0 commit comments

Comments
 (0)