diff options
author | Eli Bendersky <eliben@gmail.com> | 2012-10-07 14:23:50 (GMT) |
---|---|---|
committer | Eli Bendersky <eliben@gmail.com> | 2012-10-07 14:23:50 (GMT) |
commit | 948af23a77c41bfa77da89aa138d8a4f4111df99 (patch) | |
tree | 847db232d4c8981eeaab28055d3626899d87e477 /Doc/library/ipaddress.rst | |
parent | f4c2757d784907165e37446276138eaef5bd69ee (diff) | |
download | cpython-948af23a77c41bfa77da89aa138d8a4f4111df99.zip cpython-948af23a77c41bfa77da89aa138d8a4f4111df99.tar.gz cpython-948af23a77c41bfa77da89aa138d8a4f4111df99.tar.bz2 |
Issue #15888: fixing problems in ipaddress doctests. Patch by Chris Jerdonek
Diffstat (limited to 'Doc/library/ipaddress.rst')
-rw-r--r-- | Doc/library/ipaddress.rst | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/Doc/library/ipaddress.rst b/Doc/library/ipaddress.rst index 1046828..86d84af 100644 --- a/Doc/library/ipaddress.rst +++ b/Doc/library/ipaddress.rst @@ -42,8 +42,15 @@ IP addresses, networks and interfaces: Return an :class:`IPv4Address` or :class:`IPv6Address` object depending on the IP address passed as argument. Either IPv4 or IPv6 addresses may be supplied; integers less than 2**32 will be considered to be IPv4 by default. - A :exc:`ValueError` is raised if *address* does not represent a valid IPv4 or - IPv6 address. + A :exc:`ValueError` is raised if *address* does not represent a valid IPv4 + or IPv6 address. + +.. testsetup:: + >>> import ipaddress + >>> from ipaddress import (ip_network, IPv4Address, IPv4Interface, + ... IPv4Network) + +:: >>> ipaddress.ip_address('192.168.0.1') IPv4Address('192.168.0.1') @@ -111,7 +118,7 @@ write code that handles both IP versions correctly. >>> ipaddress.IPv4Address('192.168.0.1') IPv4Address('192.168.0.1') - >>> ipaddress.IPv4Address(3221225985) + >>> ipaddress.IPv4Address(3232235521) IPv4Address('192.168.0.1') >>> ipaddress.IPv4Address(b'\xC0\xA8\x00\x01') IPv4Address('192.168.0.1') @@ -437,7 +444,7 @@ so to avoid duplication they are only documented for :class:`IPv4Network`. hosts are all the IP addresses that belong to the network, except the network address itself and the network broadcast address. - >>> list(ip_network('192.0.2.0/29').hosts()) + >>> list(ip_network('192.0.2.0/29').hosts()) #doctest: +NORMALIZE_WHITESPACE [IPv4Address('192.0.2.1'), IPv4Address('192.0.2.2'), IPv4Address('192.0.2.3'), IPv4Address('192.0.2.4'), 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`. >>> n1 = ip_network('192.0.2.0/28') >>> n2 = ip_network('192.0.2.1/32') - >>> list(n1.address_exclude(n2)) + >>> list(n1.address_exclude(n2)) #doctest: +NORMALIZE_WHITESPACE [IPv4Network('192.0.2.8/29'), IPv4Network('192.0.2.4/30'), IPv4Network('192.0.2.2/31'), IPv4Network('192.0.2.0/32')] @@ -471,10 +478,10 @@ so to avoid duplication they are only documented for :class:`IPv4Network`. >>> list(ip_network('192.0.2.0/24').subnets()) [IPv4Network('192.0.2.0/25'), IPv4Network('192.0.2.128/25')] - >>> list(ip_network('192.0.2.0/24').subnets(prefixlen_diff=2)) + >>> list(ip_network('192.0.2.0/24').subnets(prefixlen_diff=2)) #doctest: +NORMALIZE_WHITESPACE [IPv4Network('192.0.2.0/26'), IPv4Network('192.0.2.64/26'), IPv4Network('192.0.2.128/26'), IPv4Network('192.0.2.192/26')] - >>> list(ip_network('192.0.2.0/24').subnets(new_prefix=26)) + >>> list(ip_network('192.0.2.0/24').subnets(new_prefix=26)) #doctest: +NORMALIZE_WHITESPACE [IPv4Network('192.0.2.0/26'), IPv4Network('192.0.2.64/26'), IPv4Network('192.0.2.128/26'), IPv4Network('192.0.2.192/26')] >>> list(ip_network('192.0.2.0/24').subnets(new_prefix=23)) |