aboutsummaryrefslogtreecommitdiff
path: root/test_ipaddress.py
diff options
context:
space:
mode:
Diffstat (limited to 'test_ipaddress.py')
-rw-r--r--test_ipaddress.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/test_ipaddress.py b/test_ipaddress.py
index 2cbe36a..a1721b8 100644
--- a/test_ipaddress.py
+++ b/test_ipaddress.py
@@ -862,9 +862,9 @@ class IpaddrUnitTest(unittest.TestCase):
self.ipv6_network = ipaddress.IPv6Network('2001:658:22a:cafe::/64')
def testRepr(self):
- self.assertTrue(re.match("IPv4Interface\(u?'1.2.3.4/32'\)",
+ self.assertTrue(re.match(r"IPv4Interface\(u?'1.2.3.4/32'\)",
repr(ipaddress.IPv4Interface('1.2.3.4'))))
- self.assertTrue(re.match("IPv6Interface\(u?'::1/128'\)",
+ self.assertTrue(re.match(r"IPv6Interface\(u?'::1/128'\)",
repr(ipaddress.IPv6Interface('::1'))))
# issue #16531: constructing IPv4Network from an (address, mask) tuple
@@ -1014,7 +1014,8 @@ class IpaddrUnitTest(unittest.TestCase):
[(ip1, ip3)])
self.assertEqual(128, ipaddress._count_righthand_zero_bits(0, 128))
self.assertTrue(
- re.match("IPv4Network\(u?'1.2.3.0/24'\)", repr(self.ipv4_network)))
+ re.match(r"IPv4Network\(u?'1.2.3.0/24'\)",
+ repr(self.ipv4_network)))
def testMissingAddressVersion(self):
class Broken(ipaddress._BaseAddress):
@@ -2161,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
@@ -2212,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)
@@ -2225,6 +2226,12 @@ 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()