1212import pickle
1313import ipaddress
1414import weakref
15- from test .support import LARGEST , SMALLEST
1615from collections .abc import Iterator
16+ from test .support import LARGEST , SMALLEST
1717
1818
1919class BaseTestCase (unittest .TestCase ):
@@ -1491,6 +1491,9 @@ def testHosts(self):
14911491 self .assertEqual (ipaddress .IPv6Address ('2001:658:22a:cafe::ff' ), hosts [- 1 ])
14921492
14931493 ipv6_scoped_network = ipaddress .IPv6Network ('2001:658:22a:cafe::%scope/120' )
1494+ hosts = ipv6_scoped_network .hosts ()
1495+ self .assertIsInstance (hosts , Iterator )
1496+ self .assertIsNotNone (next (hosts ))
14941497 hosts = list (ipv6_scoped_network .hosts ())
14951498 self .assertEqual (255 , len (hosts ))
14961499 self .assertEqual (ipaddress .IPv6Address ('2001:658:22a:cafe::1' ), hosts [0 ])
@@ -1501,6 +1504,12 @@ def testHosts(self):
15011504 ipaddress .IPv4Address ('2.0.0.1' )]
15021505 str_args = '2.0.0.0/31'
15031506 tpl_args = ('2.0.0.0' , 31 )
1507+ self .assertIsInstance (ipaddress .ip_network (str_args ).hosts (), Iterator )
1508+ self .assertIsInstance (ipaddress .ip_network (tpl_args ).hosts (), Iterator )
1509+ hosts = ipaddress .ip_network (str_args ).hosts ()
1510+ self .assertIsNotNone (next (hosts ))
1511+ hosts = ipaddress .ip_network (tpl_args ).hosts ()
1512+ self .assertIsNotNone (next (hosts ))
15041513 self .assertEqual (addrs , list (ipaddress .ip_network (str_args ).hosts ()))
15051514 self .assertEqual (addrs , list (ipaddress .ip_network (tpl_args ).hosts ()))
15061515 self .assertEqual (list (ipaddress .ip_network (str_args ).hosts ()),
0 commit comments