Skip to content

Commit 2bc46e7

Browse files
committed
more tests
1 parent 5e6bf4f commit 2bc46e7

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Lib/test/test_ipaddress.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
import pickle
1313
import ipaddress
1414
import weakref
15-
from test.support import LARGEST, SMALLEST
1615
from collections.abc import Iterator
16+
from test.support import LARGEST, SMALLEST
1717

1818

1919
class 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

Comments
 (0)