diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-09-11 11:41:02 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-09-11 11:41:02 (GMT) |
commit | 5f1a5187f72acb75d59fa67286ecf5c186bae619 (patch) | |
tree | c5bca32d17d3251b8887ddaa10273a7df19a0eaa /Lib/test/test_ipaddress.py | |
parent | ab8740058a7f76f1438dc18a2ffd918da4f8118d (diff) | |
download | cpython-5f1a5187f72acb75d59fa67286ecf5c186bae619.zip cpython-5f1a5187f72acb75d59fa67286ecf5c186bae619.tar.gz cpython-5f1a5187f72acb75d59fa67286ecf5c186bae619.tar.bz2 |
Use sequence repetition instead of bytes constructor with integer argument.
Diffstat (limited to 'Lib/test/test_ipaddress.py')
-rw-r--r-- | Lib/test/test_ipaddress.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Lib/test/test_ipaddress.py b/Lib/test/test_ipaddress.py index 5f08f0c..0e39516 100644 --- a/Lib/test/test_ipaddress.py +++ b/Lib/test/test_ipaddress.py @@ -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) |