aboutsummaryrefslogtreecommitdiffstats
path: root/test/netlib/test_utils.py
blob: 9dcbffd814d56242490452abffb2c4b5f4f4b8c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# coding=utf-8

from netlib import utils, tutils


def test_is_valid_host():
    assert not utils.is_valid_host(b"")
    assert utils.is_valid_host(b"one.two")
    assert not utils.is_valid_host(b"one" * 255)
    assert utils.is_valid_host(b"one.two.")


def test_bidi():
    b = utils.BiDi(a=1, b=2)
    assert b.a == 1
    assert b.get_name(1) == "a"
    assert b.get_name(5) is None
    tutils.raises(AttributeError, getattr, b, "c")
    tutils.raises(ValueError, utils.BiDi, one=1, two=1)