[Python-checkins] cpython: #14814: Fix errror message creation in ipaddress.collapse_addresses
hynek.schlawack
python-checkins at python.org
Fri Jun 1 20:21:12 CEST 2012
http://hg.python.org/cpython/rev/000cc4e0e1cd
changeset: 77284:000cc4e0e1cd
user: Hynek Schlawack <hs at ox.cx>
date: Fri Jun 01 20:12:17 2012 +0200
summary:
#14814: Fix errror message creation in ipaddress.collapse_addresses
files:
Lib/ipaddress.py | 2 +-
Lib/test/test_ipaddress.py | 15 +++++++++++----
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py
--- a/Lib/ipaddress.py
+++ b/Lib/ipaddress.py
@@ -359,7 +359,7 @@
else:
if nets and nets[-1]._version != ip._version:
raise TypeError("%s and %s are not of the same version" % (
- str(ip), str(ips[-1])))
+ str(ip), str(nets[-1])))
nets.append(ip)
# sort and dedup
diff --git a/Lib/test/test_ipaddress.py b/Lib/test/test_ipaddress.py
--- a/Lib/test/test_ipaddress.py
+++ b/Lib/test/test_ipaddress.py
@@ -596,10 +596,17 @@
self.assertEqual(list(collapsed), [ip3])
# the toejam test
- ip1 = ipaddress.ip_address('1.1.1.1')
- ip2 = ipaddress.ip_address('::1')
- self.assertRaises(TypeError, ipaddress.collapse_addresses,
- [ip1, ip2])
+ addr_tuples = [
+ (ipaddress.ip_address('1.1.1.1'),
+ ipaddress.ip_address('::1')),
+ (ipaddress.IPv4Network('1.1.0.0/24'),
+ ipaddress.IPv6Network('2001::/120')),
+ (ipaddress.IPv4Network('1.1.0.0/32'),
+ ipaddress.IPv6Network('2001::/128')),
+ ]
+ for ip1, ip2 in addr_tuples:
+ self.assertRaises(TypeError, ipaddress.collapse_addresses,
+ [ip1, ip2])
def testSummarizing(self):
#ip = ipaddress.ip_address
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list