[3.8] bpo-28577: Special case added to IP v4 and v6 hosts for /32 and… · python/cpython@10ad7eb (original) (raw)

`@@ -1124,6 +1124,15 @@ def testHosts(self):

`

1124

1124

`self.assertEqual(list(ipaddress.ip_network(str_args).hosts()),

`

1125

1125

`list(ipaddress.ip_network(tpl_args).hosts()))

`

1126

1126

``

``

1127

`+

special case where the network is a /32

`

``

1128

`+

addrs = [ipaddress.IPv4Address('1.2.3.4')]

`

``

1129

`+

str_args = '1.2.3.4/32'

`

``

1130

`+

tpl_args = ('1.2.3.4', 32)

`

``

1131

`+

self.assertEqual(addrs, list(ipaddress.ip_network(str_args).hosts()))

`

``

1132

`+

self.assertEqual(addrs, list(ipaddress.ip_network(tpl_args).hosts()))

`

``

1133

`+

self.assertEqual(list(ipaddress.ip_network(str_args).hosts()),

`

``

1134

`+

list(ipaddress.ip_network(tpl_args).hosts()))

`

``

1135

+

1127

1136

`addrs = [ipaddress.IPv6Address('2001:658:22a:cafe::'),

`

1128

1137

`ipaddress.IPv6Address('2001:658:22a:cafe::1')]

`

1129

1138

`str_args = '2001:658:22a:cafe::/127'

`

`@@ -1133,6 +1142,14 @@ def testHosts(self):

`

1133

1142

`self.assertEqual(list(ipaddress.ip_network(str_args).hosts()),

`

1134

1143

`list(ipaddress.ip_network(tpl_args).hosts()))

`

1135

1144

``

``

1145

`+

addrs = [ipaddress.IPv6Address('2001:658:22a:cafe::1'), ]

`

``

1146

`+

str_args = '2001:658:22a:cafe::1/128'

`

``

1147

`+

tpl_args = ('2001:658:22a:cafe::1', 128)

`

``

1148

`+

self.assertEqual(addrs, list(ipaddress.ip_network(str_args).hosts()))

`

``

1149

`+

self.assertEqual(addrs, list(ipaddress.ip_network(tpl_args).hosts()))

`

``

1150

`+

self.assertEqual(list(ipaddress.ip_network(str_args).hosts()),

`

``

1151

`+

list(ipaddress.ip_network(tpl_args).hosts()))

`

``

1152

+

1136

1153

`def testFancySubnetting(self):

`

1137

1154

`self.assertEqual(sorted(self.ipv4_network.subnets(prefixlen_diff=3)),

`

1138

1155

`sorted(self.ipv4_network.subnets(new_prefix=27)))

`