aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2019-10-18 02:37:37 +0200
committerPhilipp Hagemeister <phihag@phihag.de>2019-10-18 02:37:37 +0200
commit7bbbde9ca14a0399ef3b8faffbc07fb1d3f6e67c (patch)
treeb28146ee652bdf4dda7d707ed827837ebf21ce46
parente05f6e019208dbf770821ef75d5cca88fde229d9 (diff)
downloadipaddress-7bbbde9ca14a0399ef3b8faffbc07fb1d3f6e67c.tar.gz
Add a test for #48
Also, make compat code compatible to 2.6 itself.
-rw-r--r--test_ipaddress.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/test_ipaddress.py b/test_ipaddress.py
index 2cbe36a..3705ca8 100644
--- a/test_ipaddress.py
+++ b/test_ipaddress.py
@@ -2161,7 +2161,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
@@ -2212,7 +2212,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)
@@ -2225,6 +2225,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()