def test_ipv6_is_defined(self): try: from ipaddress import AddressValueError except ImportError: from ipaddr import AddressValueError self.assertRaises(ValueError, ipv6_is_defined, '2001:4860:4860::8888::1234') self.assertRaises(AddressValueError, ipv6_is_defined, 1234) self.assertEquals(ipv6_is_defined('fe80::'), (True, 'Link-Local', 'RFC 4291, Section 2.5.6')) self.assertEquals(ipv6_is_defined('2001:4860:4860::8888'), (False, '', ''))
def test_ipv6_is_defined(self): if sys.version_info >= (3, 3): from ipaddress import AddressValueError else: from ipaddr import AddressValueError self.assertRaises(ValueError, ipv6_is_defined, '2001:4860:4860::8888::1234') self.assertRaises(AddressValueError, ipv6_is_defined, 1234) self.assertEquals(ipv6_is_defined('2001:4860:4860::8888'), (False, '', '')) self.assertEquals(ipv6_is_defined('ff00::'), (True, 'Multicast', 'RFC 4291, Section 2.7')) self.assertEquals(ipv6_is_defined('0:0:0:0:0:0:0:0'), (True, 'Unspecified', 'RFC 4291, Section 2.5.2')) self.assertEquals(ipv6_is_defined('0:0:0:0:0:0:0:1'), (True, 'Loopback', 'RFC 4291, Section 2.5.3')) self.assertEquals(ipv6_is_defined('100::'), (True, 'Reserved', 'RFC 4291')) self.assertEquals(ipv6_is_defined('fe80::'), (True, 'Link-Local', 'RFC 4291, Section 2.5.6')) self.assertEquals(ipv6_is_defined('fec0::'), (True, 'Site-Local', 'RFC 4291, Section 2.5.7')) self.assertEquals(ipv6_is_defined('fc00::'), (True, 'Unique Local Unicast', 'RFC 4193'))
'Name: {0}\nRFC: {1}'.format(result[1], result[2])))) else: print(('{0}{1} is not defined{2}'.format( ANSI['yellow'] if script_args.colorize else '', script_args.ipv4_is_defined[0], ANSI['end'] if script_args.colorize else ''))) except Exception as e: print(('{0}Error{1}: {2}'.format(ANSI['red'], ANSI['end'], str(e)))) elif script_args.ipv6_is_defined: try: result = ipv6_is_defined(address=script_args.ipv6_is_defined[0]) if result[0]: print(('{0}{1} is defined{2}:\n{3}'.format( ANSI['green'] if script_args.colorize else '', script_args.ipv6_is_defined[0], ANSI['end'] if script_args.colorize else '', 'Name: {0}\nRFC: {1}'.format(result[1], result[2])))) else: print(('{0}{1} is not defined{2}'.format( ANSI['yellow'] if script_args.colorize else '', script_args.ipv6_is_defined[0], ANSI['end'] if script_args.colorize else ''))) except Exception as e:
else: print('{0}{1} is not defined{2}'.format( ANSI['yellow'] if script_args.colorize else '', script_args.ipv4_is_defined[0], ANSI['end'] if script_args.colorize else '' )) except Exception as e: print('{0}Error{1}: {2}'.format(ANSI['red'], ANSI['end'], str(e))) elif script_args.ipv6_is_defined: try: result = ipv6_is_defined(address=script_args.ipv6_is_defined[0]) if result[0]: print('{0}{1} is defined{2}:\n{3}'.format( ANSI['green'] if script_args.colorize else '', script_args.ipv6_is_defined[0], ANSI['end'] if script_args.colorize else '', 'Name: {0}\nRFC: {1}'.format(result[1], result[2]) )) else: print('{0}{1} is not defined{2}'.format( ANSI['yellow'] if script_args.colorize else '', script_args.ipv6_is_defined[0], ANSI['end'] if script_args.colorize else '' ))