Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7567865

Browse files
committed
#20815: small readability improvements in ipaddress tests.
Patch by Michel Albert. We don't normally do patches that just tweak whitespace, but ipaddress is relatively new and the package maintainers approved the patch.
1 parent 817905b commit 7567865

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

Lib/test/test_ipaddress.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import operator
1111
import ipaddress
1212

13+
1314
class BaseTestCase(unittest.TestCase):
1415
# One big change in ipaddress over the original ipaddr module is
1516
# error reporting that tries to assume users *don't know the rules*
@@ -52,17 +53,18 @@ def assertCleanError(self, exc_type, details, *args):
5253
def assertAddressError(self, details, *args):
5354
"""Ensure a clean AddressValueError"""
5455
return self.assertCleanError(ipaddress.AddressValueError,
55-
details, *args)
56+
details, *args)
5657

5758
def assertNetmaskError(self, details, *args):
5859
"""Ensure a clean NetmaskValueError"""
5960
return self.assertCleanError(ipaddress.NetmaskValueError,
60-
details, *args)
61+
details, *args)
6162

6263
def assertInstancesEqual(self, lhs, rhs):
6364
"""Check constructor arguments produce equivalent instances"""
6465
self.assertEqual(self.factory(lhs), self.factory(rhs))
6566

67+
6668
class CommonTestMixin:
6769

6870
def test_empty_address(self):
@@ -115,6 +117,7 @@ def assertBadLength(length):
115117
assertBadLength(3)
116118
assertBadLength(5)
117119

120+
118121
class CommonTestMixin_v6(CommonTestMixin):
119122

120123
def test_leading_zeros(self):
@@ -195,7 +198,7 @@ def assertBadSplit(addr):
195198
def test_empty_octet(self):
196199
def assertBadOctet(addr):
197200
with self.assertAddressError("Empty octet not permitted in %r",
198-
addr):
201+
addr):
199202
ipaddress.IPv4Address(addr)
200203

201204
assertBadOctet("42..42.42")
@@ -443,6 +446,7 @@ def assertBadNetmask(addr, netmask):
443446
class InterfaceTestCase_v4(BaseTestCase, NetmaskTestMixin_v4):
444447
factory = ipaddress.IPv4Interface
445448

449+
446450
class NetworkTestCase_v4(BaseTestCase, NetmaskTestMixin_v4):
447451
factory = ipaddress.IPv4Network
448452

@@ -496,9 +500,11 @@ def assertBadNetmask(addr, netmask):
496500
assertBadNetmask("::1", "pudding")
497501
assertBadNetmask("::", "::")
498502

503+
499504
class InterfaceTestCase_v6(BaseTestCase, NetmaskTestMixin_v6):
500505
factory = ipaddress.IPv6Interface
501506

507+
502508
class NetworkTestCase_v6(BaseTestCase, NetmaskTestMixin_v6):
503509
factory = ipaddress.IPv6Network
504510

@@ -608,7 +614,6 @@ def test_incompatible_versions(self):
608614
self.assertRaises(TypeError, v6net.__gt__, v4net)
609615

610616

611-
612617
class IpaddrUnitTest(unittest.TestCase):
613618

614619
def setUp(self):

0 commit comments

Comments
 (0)