diff options
author | R David Murray <rdmurray@bitdance.com> | 2014-10-12 19:17:44 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2014-10-12 19:17:44 (GMT) |
commit | b0f5686ba4b71a691045c108e89231580b956ba1 (patch) | |
tree | d1ee52a8b7a7228bcdda763a765b72501002c600 /Lib/test/test_ipaddress.py | |
parent | 97551744640e9fa855ace8b4d667c4e777cc2913 (diff) | |
parent | 7567865867968ddc9e914a15354e4accb417513a (diff) | |
download | cpython-b0f5686ba4b71a691045c108e89231580b956ba1.zip cpython-b0f5686ba4b71a691045c108e89231580b956ba1.tar.gz cpython-b0f5686ba4b71a691045c108e89231580b956ba1.tar.bz2 |
#20815: small readability improvements in ipaddress tests.
Diffstat (limited to 'Lib/test/test_ipaddress.py')
-rw-r--r-- | Lib/test/test_ipaddress.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Lib/test/test_ipaddress.py b/Lib/test/test_ipaddress.py index 0b71bf8..c45e142 100644 --- a/Lib/test/test_ipaddress.py +++ b/Lib/test/test_ipaddress.py @@ -10,6 +10,7 @@ import contextlib import operator import ipaddress + class BaseTestCase(unittest.TestCase): # One big change in ipaddress over the original ipaddr module is # error reporting that tries to assume users *don't know the rules* @@ -52,17 +53,18 @@ class BaseTestCase(unittest.TestCase): def assertAddressError(self, details, *args): """Ensure a clean AddressValueError""" return self.assertCleanError(ipaddress.AddressValueError, - details, *args) + details, *args) def assertNetmaskError(self, details, *args): """Ensure a clean NetmaskValueError""" return self.assertCleanError(ipaddress.NetmaskValueError, - details, *args) + details, *args) def assertInstancesEqual(self, lhs, rhs): """Check constructor arguments produce equivalent instances""" self.assertEqual(self.factory(lhs), self.factory(rhs)) + class CommonTestMixin: def test_empty_address(self): @@ -115,6 +117,7 @@ class CommonTestMixin_v4(CommonTestMixin): assertBadLength(3) assertBadLength(5) + class CommonTestMixin_v6(CommonTestMixin): def test_leading_zeros(self): @@ -195,7 +198,7 @@ class AddressTestCase_v4(BaseTestCase, CommonTestMixin_v4): def test_empty_octet(self): def assertBadOctet(addr): with self.assertAddressError("Empty octet not permitted in %r", - addr): + addr): ipaddress.IPv4Address(addr) assertBadOctet("42..42.42") @@ -443,6 +446,7 @@ class NetmaskTestMixin_v4(CommonTestMixin_v4): class InterfaceTestCase_v4(BaseTestCase, NetmaskTestMixin_v4): factory = ipaddress.IPv4Interface + class NetworkTestCase_v4(BaseTestCase, NetmaskTestMixin_v4): factory = ipaddress.IPv4Network @@ -496,9 +500,11 @@ class NetmaskTestMixin_v6(CommonTestMixin_v6): assertBadNetmask("::1", "pudding") assertBadNetmask("::", "::") + class InterfaceTestCase_v6(BaseTestCase, NetmaskTestMixin_v6): factory = ipaddress.IPv6Interface + class NetworkTestCase_v6(BaseTestCase, NetmaskTestMixin_v6): factory = ipaddress.IPv6Network @@ -608,7 +614,6 @@ class ComparisonTests(unittest.TestCase): self.assertRaises(TypeError, v6net.__gt__, v4net) - class IpaddrUnitTest(unittest.TestCase): def setUp(self): |