def test_is_valid():
    tests = (
        ('1.2.3.4', True),
        ('2.3.4.5', True),
        ('foobar', False),
        ('4.256.4.12', False),
        ('fe80::a00:27ff:fed5:56e0', True),
        ('fe80::a00:277ff:fed5:56e0', False),
        ('fe80::a00:27ff:ged5:56e0', False),
    )

    def _check(i, v):
        eq_(v, is_valid(i))

    for i, v in tests:
        yield _check, i, v
IPv4 and IPv6 addresses are OK.
dataset/ETHPy150Open jsocol/commonware/commonware/request/tests.py/test_is_valid