#20815: small readability improvements in ipaddress tests.

This commit is contained in:
R David Murray 2014-10-12 15:17:44 -04:00
commit b0f5686ba4
1 changed files with 9 additions and 4 deletions

View File

@ -10,6 +10,7 @@ import contextlib
import operator import operator
import ipaddress import ipaddress
class BaseTestCase(unittest.TestCase): class BaseTestCase(unittest.TestCase):
# One big change in ipaddress over the original ipaddr module is # One big change in ipaddress over the original ipaddr module is
# error reporting that tries to assume users *don't know the rules* # error reporting that tries to assume users *don't know the rules*
@ -63,6 +64,7 @@ class BaseTestCase(unittest.TestCase):
"""Check constructor arguments produce equivalent instances""" """Check constructor arguments produce equivalent instances"""
self.assertEqual(self.factory(lhs), self.factory(rhs)) self.assertEqual(self.factory(lhs), self.factory(rhs))
class CommonTestMixin: class CommonTestMixin:
def test_empty_address(self): def test_empty_address(self):
@ -115,6 +117,7 @@ class CommonTestMixin_v4(CommonTestMixin):
assertBadLength(3) assertBadLength(3)
assertBadLength(5) assertBadLength(5)
class CommonTestMixin_v6(CommonTestMixin): class CommonTestMixin_v6(CommonTestMixin):
def test_leading_zeros(self): def test_leading_zeros(self):
@ -443,6 +446,7 @@ class NetmaskTestMixin_v4(CommonTestMixin_v4):
class InterfaceTestCase_v4(BaseTestCase, NetmaskTestMixin_v4): class InterfaceTestCase_v4(BaseTestCase, NetmaskTestMixin_v4):
factory = ipaddress.IPv4Interface factory = ipaddress.IPv4Interface
class NetworkTestCase_v4(BaseTestCase, NetmaskTestMixin_v4): class NetworkTestCase_v4(BaseTestCase, NetmaskTestMixin_v4):
factory = ipaddress.IPv4Network factory = ipaddress.IPv4Network
@ -496,9 +500,11 @@ class NetmaskTestMixin_v6(CommonTestMixin_v6):
assertBadNetmask("::1", "pudding") assertBadNetmask("::1", "pudding")
assertBadNetmask("::", "::") assertBadNetmask("::", "::")
class InterfaceTestCase_v6(BaseTestCase, NetmaskTestMixin_v6): class InterfaceTestCase_v6(BaseTestCase, NetmaskTestMixin_v6):
factory = ipaddress.IPv6Interface factory = ipaddress.IPv6Interface
class NetworkTestCase_v6(BaseTestCase, NetmaskTestMixin_v6): class NetworkTestCase_v6(BaseTestCase, NetmaskTestMixin_v6):
factory = ipaddress.IPv6Network factory = ipaddress.IPv6Network
@ -608,7 +614,6 @@ class ComparisonTests(unittest.TestCase):
self.assertRaises(TypeError, v6net.__gt__, v4net) self.assertRaises(TypeError, v6net.__gt__, v4net)
class IpaddrUnitTest(unittest.TestCase): class IpaddrUnitTest(unittest.TestCase):
def setUp(self): def setUp(self):