mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
Issue 14814: Explain how to get more error detail in the ipaddress tutorial, and tweak the display for octet errors in IPv4 (noticed the formatting problem when adding to the docs)
This commit is contained in:
parent
01ac8b6ab1
commit
b582ecc562
3 changed files with 43 additions and 16 deletions
|
|
@ -126,8 +126,8 @@ class AddressErrors_v4(ErrorReporting):
|
|||
|
||||
def test_octet_limit(self):
|
||||
def assertBadOctet(addr, octet):
|
||||
msg = "Octet %d > 255 not permitted in %r"
|
||||
with self.assertAddressError(msg, octet, addr):
|
||||
msg = "Octet %d (> 255) not permitted in %r" % (octet, addr)
|
||||
with self.assertAddressError(re.escape(msg)):
|
||||
ipaddress.IPv4Address(addr)
|
||||
|
||||
assertBadOctet("12345.67899.-54321.-98765", 12345)
|
||||
|
|
@ -310,7 +310,7 @@ class NetmaskErrorsMixin_v4:
|
|||
assertBadAddress("google.com", "Expected 4 octets")
|
||||
assertBadAddress("10/8", "Expected 4 octets")
|
||||
assertBadAddress("::1.2.3.4", "Only decimal digits")
|
||||
assertBadAddress("1.2.3.256", "256 > 255")
|
||||
assertBadAddress("1.2.3.256", re.escape("256 (> 255)"))
|
||||
|
||||
def test_netmask_errors(self):
|
||||
def assertBadNetmask(addr, netmask):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue