Exemplo n.º 1
0
 def test_integer(self):
     a = address.IPAddress("255.255.255.255")
     assert a.integer == 2**32 - 1
     a = address.IPAddress("0.0.0.1")
     assert a.integer == 1
     a = address.IPAddress("255.0.0.0")
     assert a.integer == 255 << 24
Exemplo n.º 2
0
    def test_range(self):
        a = address.IPAddress("192.168.0.1")
        m = a.mask("255.255.0.0")
        x, y = a.range(m)
        assert x == "192.168.0.0"
        assert y == "192.168.255.255"

        a = address.IPAddress("192.168.0.1")
        m = a.mask("255.255.255.255")
        x, y = a.range(m)
        assert x == "192.168.0.1"
        assert y == "192.168.0.1"

        a = address.IPAddress("192.168.0.1")
        m = a.mask("0.0.0.0")
        x, y = a.range(m)
        assert x == "0.0.0.0"
        assert y == "255.255.255.255"

        a = address.IPAddress("172.16.0.0")
        m = a.mask(12)
        x, y = a.range(m)
        assert x == "172.16.0.0"
        assert y == "172.31.255.255"
Exemplo n.º 3
0
 def _roundtrip(self, a):
     a = address.IPAddress(a)
     i = a.integer
     b = address.IPAddress.fromInteger(i)
     assert a == b
Exemplo n.º 4
0
 def test_init(self):
     a = address.IPAddress("192.168.0.1")
     a.mask("255.255.0.0")
     repr(a)
Exemplo n.º 5
0
 def test_inNetwork(self):
     a = address.IPAddress("192.168.0.1")
     m = a.mask("255.255.0.0")
     assert address.IPAddress("192.168.0.5").inNetwork(a, m)
     assert address.IPAddress("192.168.255.5").inNetwork(a, m)
     assert not address.IPAddress("192.169.0.5").inNetwork(a, m)