summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-05-02 17:33:01 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-05-02 17:33:01 (GMT)
commit62821691426f06cf7632b28d730e405fa31dead7 (patch)
tree881446a2402d8f8c4e0cb64d425d78ed41990bac /Lib/test
parent92b970037b12cc3471c9db48959af071351cffee (diff)
downloadcpython-62821691426f06cf7632b28d730e405fa31dead7.zip
cpython-62821691426f06cf7632b28d730e405fa31dead7.tar.gz
cpython-62821691426f06cf7632b28d730e405fa31dead7.tar.bz2
remove py3k compat code
Diffstat (limited to 'Lib/test')
-rwxr-xr-xLib/test/test_ipaddr.py42
1 files changed, 7 insertions, 35 deletions
diff --git a/Lib/test/test_ipaddr.py b/Lib/test/test_ipaddr.py
index 16ebb86..6ab581c 100755
--- a/Lib/test/test_ipaddr.py
+++ b/Lib/test/test_ipaddr.py
@@ -22,12 +22,6 @@ import unittest
import ipaddr
-# Compatibility function to cast str to bytes objects
-if ipaddr._compat_has_real_bytes:
- _cb = lambda bytestr: bytes(bytestr, 'charmap')
-else:
- _cb = str
-
class IpaddrUnitTest(unittest.TestCase):
def setUp(self):
@@ -99,27 +93,6 @@ class IpaddrUnitTest(unittest.TestCase):
self.assertEqual(ipaddr.IP(self.ipv4.ip).version, 4)
self.assertEqual(ipaddr.IP(self.ipv6.ip).version, 6)
- if ipaddr._compat_has_real_bytes: # on python3+
- def testIpFromPacked(self):
- ip = ipaddr.IP
-
- self.assertEqual(self.ipv4.ip,
- ip(_cb('\x01\x02\x03\x04')).ip)
- self.assertEqual(ip('255.254.253.252'),
- ip(_cb('\xff\xfe\xfd\xfc')))
- self.assertRaises(ValueError, ipaddr.IP, _cb('\x00' * 3))
- self.assertRaises(ValueError, ipaddr.IP, _cb('\x00' * 5))
- self.assertEqual(self.ipv6.ip,
- ip(_cb('\x20\x01\x06\x58\x02\x2a\xca\xfe'
- '\x02\x00\x00\x00\x00\x00\x00\x01')).ip)
- self.assertEqual(ip('ffff:2:3:4:ffff::'),
- ip(_cb('\xff\xff\x00\x02\x00\x03\x00\x04' +
- '\xff\xff' + '\x00' * 6)))
- self.assertEqual(ip('::'),
- ip(_cb('\x00' * 16)))
- self.assertRaises(ValueError, ip, _cb('\x00' * 15))
- self.assertRaises(ValueError, ip, _cb('\x00' * 17))
-
def testGetIp(self):
self.assertEqual(self.ipv4.ip, 16909060)
self.assertEqual(self.ipv4.ip_ext, '1.2.3.4')
@@ -403,18 +376,17 @@ class IpaddrUnitTest(unittest.TestCase):
self.assertEqual(self.ipv6.version, 6)
def testPacked(self):
- self.assertEqual(self.ipv4.packed,
- _cb('\x01\x02\x03\x04'))
+ self.assertEqual(self.ipv4.packed, '\x01\x02\x03\x04')
self.assertEqual(ipaddr.IPv4('255.254.253.252').packed,
- _cb('\xff\xfe\xfd\xfc'))
+ '\xff\xfe\xfd\xfc')
self.assertEqual(self.ipv6.packed,
- _cb('\x20\x01\x06\x58\x02\x2a\xca\xfe'
- '\x02\x00\x00\x00\x00\x00\x00\x01'))
+ '\x20\x01\x06\x58\x02\x2a\xca\xfe'
+ + '\x02\x00\x00\x00\x00\x00\x00\x01')
self.assertEqual(ipaddr.IPv6('ffff:2:3:4:ffff::').packed,
- _cb('\xff\xff\x00\x02\x00\x03\x00\x04\xff\xff'
- + '\x00' * 6))
+ '\xff\xff\x00\x02\x00\x03\x00\x04\xff\xff'
+ + '\x00' * 6)
self.assertEqual(ipaddr.IPv6('::1:0:0:0:0').packed,
- _cb('\x00' * 6 + '\x00\x01' + '\x00' * 8))
+ '\x00' * 6 + '\x00\x01' + '\x00' * 8)
def testIpStrFromPrefixlen(self):
ipv4 = ipaddr.IPv4('1.2.3.4/24')