@@ -1475,7 +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 ))
1478+ self .assertEqual ( ipaddress . IPv4Address ( '1.2.3.1' ), next (hosts ))
14791479 hosts = list (self .ipv4_network .hosts ())
14801480 self .assertEqual (254 , len (hosts ))
14811481 self .assertEqual (ipaddress .IPv4Address ('1.2.3.1' ), hosts [0 ])
@@ -1484,7 +1484,7 @@ def testHosts(self):
14841484 ipv6_network = ipaddress .IPv6Network ('2001:658:22a:cafe::/120' )
14851485 hosts = ipv6_network .hosts ()
14861486 self .assertIsInstance (hosts , Iterator )
1487- self .assertIsNotNone ( next (hosts ))
1487+ self .assertEqual ( ipaddress . IPv6Address ( '2001:658:22a:cafe::1' ), next (hosts ))
14881488 hosts = list (ipv6_network .hosts ())
14891489 self .assertEqual (255 , len (hosts ))
14901490 self .assertEqual (ipaddress .IPv6Address ('2001:658:22a:cafe::1' ), hosts [0 ])
@@ -1493,7 +1493,7 @@ def testHosts(self):
14931493 ipv6_scoped_network = ipaddress .IPv6Network ('2001:658:22a:cafe::%scope/120' )
14941494 hosts = ipv6_scoped_network .hosts ()
14951495 self .assertIsInstance (hosts , Iterator )
1496- self .assertIsNotNone ( next (hosts ))
1496+ self .assertEqual (( ipaddress . IPv6Address ( '2001:658:22a:cafe::1' )), next (hosts ))
14971497 hosts = list (ipv6_scoped_network .hosts ())
14981498 self .assertEqual (255 , len (hosts ))
14991499 self .assertEqual (ipaddress .IPv6Address ('2001:658:22a:cafe::1' ), hosts [0 ])
@@ -1504,12 +1504,12 @@ def testHosts(self):
15041504 ipaddress .IPv4Address ('2.0.0.1' )]
15051505 str_args = '2.0.0.0/31'
15061506 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 )
15091507 hosts = ipaddress .ip_network (str_args ).hosts ()
1510- self .assertIsNotNone (next (hosts ))
1508+ self .assertIsInstance (hosts , Iterator )
1509+ self .assertEqual (next (hosts ), addrs [0 ])
15111510 hosts = ipaddress .ip_network (tpl_args ).hosts ()
1512- self .assertIsNotNone (next (hosts ))
1511+ self .assertIsInstance (hosts , Iterator )
1512+ self .assertEqual (next (hosts ), addrs [0 ])
15131513 self .assertEqual (addrs , list (ipaddress .ip_network (str_args ).hosts ()))
15141514 self .assertEqual (addrs , list (ipaddress .ip_network (tpl_args ).hosts ()))
15151515 self .assertEqual (list (ipaddress .ip_network (str_args ).hosts ()),
@@ -1519,12 +1519,12 @@ def testHosts(self):
15191519 addrs = [ipaddress .IPv4Address ('1.2.3.4' )]
15201520 str_args = '1.2.3.4/32'
15211521 tpl_args = ('1.2.3.4' , 32 )
1522- self .assertIsInstance (ipaddress .ip_network (str_args ).hosts (), Iterator )
1523- self .assertIsInstance (ipaddress .ip_network (tpl_args ).hosts (), Iterator )
15241522 hosts = ipaddress .ip_network (str_args ).hosts ()
1525- self .assertIsNotNone (next (hosts ))
1523+ self .assertIsInstance (hosts , Iterator )
1524+ self .assertEqual (next (hosts ), addrs [0 ])
15261525 hosts = ipaddress .ip_network (tpl_args ).hosts ()
1527- self .assertIsNotNone (next (hosts ))
1526+ self .assertIsInstance (hosts , Iterator )
1527+ self .assertEqual (next (hosts ), addrs [0 ])
15281528 self .assertEqual (addrs , list (ipaddress .ip_network (str_args ).hosts ()))
15291529 self .assertEqual (addrs , list (ipaddress .ip_network (tpl_args ).hosts ()))
15301530 self .assertEqual (list (ipaddress .ip_network (str_args ).hosts ()),
@@ -1534,12 +1534,12 @@ def testHosts(self):
15341534 ipaddress .IPv6Address ('2001:658:22a:cafe::1' )]
15351535 str_args = '2001:658:22a:cafe::/127'
15361536 tpl_args = ('2001:658:22a:cafe::' , 127 )
1537- self .assertIsInstance (ipaddress .ip_network (str_args ).hosts (), Iterator )
1538- self .assertIsInstance (ipaddress .ip_network (tpl_args ).hosts (), Iterator )
15391537 hosts = ipaddress .ip_network (str_args ).hosts ()
1540- self .assertIsNotNone (next (hosts ))
1538+ self .assertIsInstance (hosts , Iterator )
1539+ self .assertEqual (next (hosts ), addrs [0 ])
15411540 hosts = ipaddress .ip_network (tpl_args ).hosts ()
1542- self .assertIsNotNone (next (hosts ))
1541+ self .assertIsInstance (hosts , Iterator )
1542+ self .assertEqual (next (hosts ), addrs [0 ])
15431543 self .assertEqual (addrs , list (ipaddress .ip_network (str_args ).hosts ()))
15441544 self .assertEqual (addrs , list (ipaddress .ip_network (tpl_args ).hosts ()))
15451545 self .assertEqual (list (ipaddress .ip_network (str_args ).hosts ()),
@@ -1548,12 +1548,12 @@ def testHosts(self):
15481548 addrs = [ipaddress .IPv6Address ('2001:658:22a:cafe::1' ), ]
15491549 str_args = '2001:658:22a:cafe::1/128'
15501550 tpl_args = ('2001:658:22a:cafe::1' , 128 )
1551- self .assertIsInstance (ipaddress .ip_network (str_args ).hosts (), Iterator )
1552- self .assertIsInstance (ipaddress .ip_network (tpl_args ).hosts (), Iterator )
15531551 hosts = ipaddress .ip_network (str_args ).hosts ()
1554- self .assertIsNotNone (next (hosts ))
1552+ self .assertIsInstance (hosts , Iterator )
1553+ self .assertEqual (next (hosts ), addrs [0 ])
15551554 hosts = ipaddress .ip_network (tpl_args ).hosts ()
1556- self .assertIsNotNone (next (hosts ))
1555+ self .assertIsInstance (hosts , Iterator )
1556+ self .assertEqual (next (hosts ), addrs [0 ])
15571557 self .assertEqual (addrs , list (ipaddress .ip_network (str_args ).hosts ()))
15581558 self .assertEqual (addrs , list (ipaddress .ip_network (tpl_args ).hosts ()))
15591559 self .assertEqual (list (ipaddress .ip_network (str_args ).hosts ()),
0 commit comments