<filename>netaddr/tests/ip/test_ip_categories.py
from netaddr import IPAddress


def test_is_unicast():
    assert IPAddress('192.0.2.1').is_unicast()
    assert IPAddress('fe80::1').is_unicast()


def test_is_multicast():
    assert IPAddress('172.16.31.10').is_multicast()
    assert IPAddress('fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b').is_multicast()


def test_is_private():
    assert IPAddress('172.24.0.1').is_private()
    assert IPAddress('10.0.0.1').is_private()
    assert IPAddress('192.168.0.1').is_private()
    assert IPAddress('fc00::1').is_private()
    assert IPAddress('198.18.0.0').is_private()
    assert IPAddress('198.19.255.255').is_private()


def test_is_reserved():
    assert IPAddress('253.0.0.1').is_reserved()
    assert IPAddress('192.0.2.0').is_reserved()
    assert IPAddress('192.0.2.255').is_reserved()
    assert IPAddress('127.0.0.0').is_reserved()
    assert IPAddress('127.255.255.255').is_reserved()
    assert IPAddress('192.168.3.11').is_reserved()
    assert IPAddress('172.16.58.3').is_reserved()
    assert IPAddress('0.0.0.0').is_reserved()
    assert IPAddress('0.255.255.255').is_reserved()
    assert IPAddress('172.16.58.3').is_reserved()
    assert IPAddress('172.16.17.32').is_reserved()


def test_is_public():
    ip = IPAddress('172.16.31.10')
    assert ip.is_unicast() and not ip.is_private()


def test_is_netmask():
    assert IPAddress('255.255.254.0').is_netmask()


def test_is_hostmask():
    assert IPAddress('0.0.1.255').is_hostmask()


def test_is_loopback():
    assert IPAddress('127.0.0.1').is_loopback()
    assert IPAddress('::1').is_loopback()

<filename>netaddr/tests/ip/test_ip_categories.py
from netaddr import IPAddress


def test_is_unicast():
    assert IPAddress('192.0.2.1').is_unicast()
    assert IPAddress('fe80::1').is_unicast()


def test_is_multicast():
    assert IPAddress('172.16.31.10').is_multicast()
    assert IPAddress('fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b').is_multicast()


def test_is_private():
    assert IPAddress('172.24.0.1').is_private()
    assert IPAddress('10.0.0.1').is_private()
    assert IPAddress('192.168.0.1').is_private()
    assert IPAddress('fc00::1').is_private()
    assert IPAddress('198.18.0.0').is_private()
    assert IPAddress('198.19.255.255').is_private()


def test_is_reserved():
    assert IPAddress('253.0.0.1').is_reserved()
    assert IPAddress('192.0.2.0').is_reserved()
    assert IPAddress('192.0.2.255').is_reserved()
    assert IPAddress('127.0.0.0').is_reserved()
    assert IPAddress('127.255.255.255').is_reserved()
    assert IPAddress('192.168.3.11').is_reserved()
    assert IPAddress('172.16.58.3').is_reserved()
    assert IPAddress('0.0.0.0').is_reserved()
    assert IPAddress('0.255.255.255').is_reserved()
    assert IPAddress('172.16.58.3').is_reserved()
    assert IPAddress('172.16.17.32').is_reserved()


def test_is_public():
    ip = IPAddress('172.16.31.10')
    assert ip.is_unicast() and not ip.is_private()


def test_is_netmask():
    assert IPAddress('255.255.254.0').is_netmask()


def test_is_hostmask():
    assert IPAddress('0.0.1.255').is_hostmask()


def test_is_loopback():
    assert IPAddress('127.0.0.1').is_loopback()
    assert IPAddress('::1').is_loopback()
