diff options
-rw-r--r-- | .dockerignore | 3 | ||||
-rw-r--r-- | .travis.yml | 1 | ||||
-rw-r--r-- | Dockerfile.python2.6 | 8 | ||||
-rw-r--r-- | ipaddress.py | 3 | ||||
-rw-r--r-- | test_ipaddress.py | 9 |
5 files changed, 21 insertions, 3 deletions
diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..c778784 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +build +dist +ipaddress.egg-info diff --git a/.travis.yml b/.travis.yml index ddc269c..9e2469a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ +dist: "trusty" language: python python: - "2.6" diff --git a/Dockerfile.python2.6 b/Dockerfile.python2.6 new file mode 100644 index 0000000..1c11f9f --- /dev/null +++ b/Dockerfile.python2.6 @@ -0,0 +1,8 @@ +FROM lovato/python-2.6.6 +# Dockerfile to run tests under python2.6 + +# docker build -t ipaddress-python2.6 . -f Dockerfile.python2.6 + +ADD . . +RUN python test_ipaddress.py +CMD python test_ipaddress.py diff --git a/ipaddress.py b/ipaddress.py index f2d0766..8e09243 100644 --- a/ipaddress.py +++ b/ipaddress.py @@ -1103,7 +1103,8 @@ class _BaseNetwork(_IPAddressBase): try: # Always false if one is v4 and the other is v6. if a._version != b._version: - raise TypeError("%s and %s are not of the same version" (a, b)) + raise TypeError( + "%s and %s are not of the same version" % (a, b)) return (b.network_address <= a.network_address and b.broadcast_address >= a.broadcast_address) except AttributeError: diff --git a/test_ipaddress.py b/test_ipaddress.py index 18b103d..37d4990 100644 --- a/test_ipaddress.py +++ b/test_ipaddress.py @@ -2162,7 +2162,7 @@ if not hasattr(BaseTestCase, 'assertRaisesRegex'): expected_regex = self.expected_regex if not expected_regex.search(str(exc_value)): - raise AssertionError('"{}" does not match "{}"'.format( + raise AssertionError('"{0}" does not match "{1}"'.format( expected_regex.pattern, str(exc_value))) return True @@ -2213,7 +2213,7 @@ class CompatTest(unittest.TestCase): self.assertEqual(ipaddress._compat_bit_length(4), 3) -class SingleIssuesTest(unittest.TestCase): +class SingleIssuesTest(BaseTestCase): # https://github.com/phihag/ipaddress/issues/14 def test_issue_14(self): self.assertTrue(ipaddress.ip_address('127.0.0.1').is_private) @@ -2226,6 +2226,11 @@ class SingleIssuesTest(unittest.TestCase): self.assertTrue(net2.subnet_of(net1)) self.assertFalse(net2.supernet_of(net1)) + def test_issue_48(self): + v6net = ipaddress.ip_network('::/0') + v4net = ipaddress.ip_network('1.2.3.0/24') + with self.assertRaisesRegex(TypeError, r'are not of the same version'): + v6net.subnet_of(v4net) if __name__ == '__main__': unittest.main() |