@@ -42,8 +42,15 @@ IP addresses, networks and interfaces:
4242 Return an :class: `IPv4Address ` or :class: `IPv6Address ` object depending on
4343 the IP address passed as argument. Either IPv4 or IPv6 addresses may be
4444 supplied; integers less than 2**32 will be considered to be IPv4 by default.
45- A :exc: `ValueError ` is raised if *address * does not represent a valid IPv4 or
46- IPv6 address.
45+ A :exc: `ValueError ` is raised if *address * does not represent a valid IPv4
46+ or IPv6 address.
47+
48+ .. testsetup ::
49+ >>> import ipaddress
50+ >>> from ipaddress import (ip_network, IPv4Address, IPv4Interface,
51+ ... IPv4Network)
52+
53+ ::
4754
4855 >>> ipaddress.ip_address('192.168.0.1')
4956 IPv4Address('192.168.0.1')
@@ -111,7 +118,7 @@ write code that handles both IP versions correctly.
111118
112119 >>> ipaddress.IPv4Address(' 192.168.0.1' )
113120 IPv4Address('192.168.0.1')
114- >>> ipaddress.IPv4Address(3221225985 )
121+ >>> ipaddress.IPv4Address(3232235521 )
115122 IPv4Address('192.168.0.1')
116123 >>> ipaddress.IPv4Address(b ' \xC0\xA8\x00\x01 ' )
117124 IPv4Address('192.168.0.1')
@@ -437,7 +444,7 @@ so to avoid duplication they are only documented for :class:`IPv4Network`.
437444 hosts are all the IP addresses that belong to the network, except the
438445 network address itself and the network broadcast address.
439446
440- >>> list (ip_network(' 192.0.2.0/29' ).hosts())
447+ >>> list (ip_network(' 192.0.2.0/29' ).hosts()) # doctest: +NORMALIZE_WHITESPACE
441448 [IPv4Address('192.0.2.1'), IPv4Address('192.0.2.2'),
442449 IPv4Address('192.0.2.3'), IPv4Address('192.0.2.4'),
443450 IPv4Address('192.0.2.5'), IPv4Address('192.0.2.6')]
@@ -456,7 +463,7 @@ so to avoid duplication they are only documented for :class:`IPv4Network`.
456463
457464 >>> n1 = ip_network(' 192.0.2.0/28' )
458465 >>> n2 = ip_network(' 192.0.2.1/32' )
459- >>> list (n1.address_exclude(n2))
466+ >>> list (n1.address_exclude(n2)) # doctest: +NORMALIZE_WHITESPACE
460467 [IPv4Network('192.0.2.8/29'), IPv4Network('192.0.2.4/30'),
461468 IPv4Network('192.0.2.2/31'), IPv4Network('192.0.2.0/32')]
462469
@@ -471,10 +478,10 @@ so to avoid duplication they are only documented for :class:`IPv4Network`.
471478
472479 >>> list (ip_network(' 192.0.2.0/24' ).subnets())
473480 [IPv4Network('192.0.2.0/25'), IPv4Network('192.0.2.128/25')]
474- >>> list (ip_network(' 192.0.2.0/24' ).subnets(prefixlen_diff = 2 ))
481+ >>> list (ip_network(' 192.0.2.0/24' ).subnets(prefixlen_diff = 2 )) # doctest: +NORMALIZE_WHITESPACE
475482 [IPv4Network('192.0.2.0/26'), IPv4Network('192.0.2.64/26'),
476483 IPv4Network('192.0.2.128/26'), IPv4Network('192.0.2.192/26')]
477- >>> list (ip_network(' 192.0.2.0/24' ).subnets(new_prefix = 26 ))
484+ >>> list (ip_network(' 192.0.2.0/24' ).subnets(new_prefix = 26 )) # doctest: +NORMALIZE_WHITESPACE
478485 [IPv4Network('192.0.2.0/26'), IPv4Network('192.0.2.64/26'),
479486 IPv4Network('192.0.2.128/26'), IPv4Network('192.0.2.192/26')]
480487 >>> list (ip_network(' 192.0.2.0/24' ).subnets(new_prefix = 23 ))
0 commit comments