from unittest import TestCase

from ipfromwebpage import *


class TestValidate_url(TestCase):
    def test_valid_url(self):
        self.assertTrue(validate_url('http://www.example.com'))

    def test_no_protocol(self):
        self.assertFalse(validate_url('www.example.com'))

    def test_not_http_protocol(self):
        self.assertFalse(validate_url('ftp://www.example.com'))

    def test_custom_tld(self):
        self.assertTrue(validate_url('http://www.example.anything'))

    def test_malformed_url(self):
        self.assertFalse(validate_url('http://example'))

class TestValidate_Ip(TestCase):
    def test_valid_ipv4(self):
        self.assertTrue(validate_ip('192.168.0.1'))

    def test_valid_ipv4network(self):
        self.assertTrue(validate_ip('192.0.0.0/24'))

    def test_valid_ipv6(self):
        self.assertTrue(validate_ip('::1'))

    def test_word(self):
        self.assertFalse(validate_ip('word'))

    def test_invalid(self):
        self.assertFalse(validate_ip('999.999.999.999'))

    def test_close(self):
        self.assertFalse(validate_ip('1234.12341.12.3.3.4'))


class TestIp_from_string(TestCase):
    def test_empty(self):
        self.assertEqual(ip_from_string(''), set())

    def test_valid_multiple(self):
        self.assertEquals(ip_from_string('192.168.0.1 192.168.5.5'), {'192.168.0.1', '192.168.5.5'})

    def test_duplicates(self):
        self.assertEquals(ip_from_string('192.168.0.4 10.2.3.4 192.168.0.4 10.2.3.4'), {'192.168.0.4', '10.2.3.4'})

    def test_newline(self):
        self.assertEqual(ip_from_string('\n192.168.0.1\n10.0.0.1\n'), {'192.168.0.1', '10.0.0.1'})

@@ -570,16 +570,17 @@
 ple'))%0A%0A
+%0A
 class Te
@@ -1210,17 +1210,27 @@
 ng(''), 
-s
+netaddr.IPS
 et())%0A%0A 
@@ -1331,18 +1331,58 @@
 8.5.5'),
- %7B
+%0A                          netaddr.IPSet(%5B
 '192.168
@@ -1401,17 +1401,18 @@
 168.5.5'
-%7D
+%5D)
 )%0A%0A    d
@@ -1523,18 +1523,58 @@
 2.3.4'),
- %7B
+%0A                          netaddr.IPSet(%5B
 '192.168
@@ -1590,17 +1590,18 @@
 0.2.3.4'
-%7D
+%5D)
 )%0A%0A    d
@@ -1696,10 +1696,49 @@
 n'),
- %7B
+%0A                         netaddr.IPSet(%5B
 '192
@@ -1762,7 +1762,8 @@
 0.1'
-%7D
+%5D)
 )%0A

Replace ipaddress with netaddr