|
|
|
@ -119,7 +119,7 @@ class CommonTestMixin_v4(CommonTestMixin): |
|
|
|
|
|
|
|
def test_bad_packed_length(self): |
|
|
|
def assertBadLength(length): |
|
|
|
addr = bytes(length) |
|
|
|
addr = b'\0' * length |
|
|
|
msg = "%r (len %d != 4) is not permitted as an IPv4 address" |
|
|
|
with self.assertAddressError(re.escape(msg % (addr, length))): |
|
|
|
self.factory(addr) |
|
|
|
@ -139,11 +139,11 @@ class CommonTestMixin_v6(CommonTestMixin): |
|
|
|
self.assertInstancesEqual(3232235521, "::c0a8:1") |
|
|
|
|
|
|
|
def test_packed(self): |
|
|
|
addr = bytes(12) + bytes.fromhex("00000000") |
|
|
|
addr = b'\0'*12 + bytes.fromhex("00000000") |
|
|
|
self.assertInstancesEqual(addr, "::") |
|
|
|
addr = bytes(12) + bytes.fromhex("c0a80001") |
|
|
|
addr = b'\0'*12 + bytes.fromhex("c0a80001") |
|
|
|
self.assertInstancesEqual(addr, "::c0a8:1") |
|
|
|
addr = bytes.fromhex("c0a80001") + bytes(12) |
|
|
|
addr = bytes.fromhex("c0a80001") + b'\0'*12 |
|
|
|
self.assertInstancesEqual(addr, "c0a8:1::") |
|
|
|
|
|
|
|
def test_negative_ints_rejected(self): |
|
|
|
@ -158,7 +158,7 @@ class CommonTestMixin_v6(CommonTestMixin): |
|
|
|
|
|
|
|
def test_bad_packed_length(self): |
|
|
|
def assertBadLength(length): |
|
|
|
addr = bytes(length) |
|
|
|
addr = b'\0' * length |
|
|
|
msg = "%r (len %d != 16) is not permitted as an IPv6 address" |
|
|
|
with self.assertAddressError(re.escape(msg % (addr, length))): |
|
|
|
self.factory(addr) |
|
|
|
|