All pastes #222706 Raw Edit

Miscellany

public python v1 · immutable
#222706 ·published 2006-10-26 14:23 UTC
rendered paste body
class RegressionTest(unittest.TestCase):    def testNulNetmask(self):        ip = timeout(IPy.IP, ["0.0.0.0/0.0.0.0"], timeout_duration=0.250, default=None)        if ip:            text = str(ip)        else:            text = "*TIMEOUT*"        self.assertEqual(text, "0.0.0.0/0")    def testNonZeroType(self):        ip = IPy.IP("0.0.0.0/0")        self.assertEqual(bool(ip), True)    def testPrivate169(self):        """        RFC 3330 indicates that 169.254.0.0/16 addresses are private.        They are automatically configured for links in the absence of other        information and should not be used on the internet        """        self.assertEqual(IPy.IP("169.254.191.164").iptype(), "PRIVATE")    def testCheckAddrPrefixlenOn(self):        self.assertEqual(len(IPy.IP('192.168.0.0/24')), 256)        self.assertRaises(ValueError, IPy.IP, '192.168.1.0/42')        self.assertRaises(ValueError, IPy.IP, '172.30.1.0/22')    def testCheckAddrPrefixlenOff(self):        old = IPy.check_addr_prefixlen        IPy.check_addr_prefixlen = False        try:            self.assertEqual(len(IPy.IP('192.168.0.0/24')), 256)            self.assertRaises(ValueError, IPy.IP, '192.168.1.0/42')            self.assertEqual(len(IPy.IP('172.30.1.0/22')), 1024)        finally:            IPy.check_addr_prefixlen = old