示例#1
0
def test_case_insensitivity():
    h = Headers({'Content-Type': 'text/plain'})
    h.add('Content-Encoding', 'utf8')
    for val in ('content-type', 'content-encoding'):
        assert val.upper() in h
        assert val.lower() in h
        assert val.capitalize() in h
        assert h.get(val.lower()) == h.get(val.upper()) == h.get(val.capitalize())
        del h[val.upper()]
        assert val.lower() not in h
示例#2
0
def test_fieldname_string_enforcement():
    with pytest.raises(TypeError):  #@UndefinedVariable
        Headers({3: 3})
    h = Headers()
    with pytest.raises(TypeError):  #@UndefinedVariable
        h[3] = 5
    with pytest.raises(TypeError):  #@UndefinedVariable
        h.add(3, 4)
    with pytest.raises(TypeError):  #@UndefinedVariable
        del h[3]
示例#3
0
def test_fieldname_string_enforcement():
    with pytest.raises(Exception):
        Headers({3: 3})
    h = Headers()
    with pytest.raises(Exception):
        h[3] = 5
    with pytest.raises(Exception):
        h.add(3, 4)
    with pytest.raises(Exception):
        del h[3]
示例#4
0
def test_fieldname_string_enforcement():
    with pytest.raises(Exception):
        Headers({3: 3})
    h = Headers()
    with pytest.raises(Exception):
        h[3] = 5
    with pytest.raises(Exception):
        h.add(3, 4)
    with pytest.raises(Exception):
        del h[3]
def test_case_insensitivity():
    h = Headers({"Content-Type": "text/plain"})
    h.add("Content-Encoding", "utf8")
    for val in ("content-type", "content-encoding"):
        assert val.upper() in h
        assert val.lower() in h
        assert val.capitalize() in h
        assert h.get(val.lower()) == h.get(val.upper()) == h.get(val.capitalize())
        del h[val.upper()]
        assert val.lower() not in h
示例#6
0
def test_fieldname_string_enforcement():
    with pytest.raises(TypeError): #@UndefinedVariable
        Headers({3: 3})
    h = Headers()
    with pytest.raises(TypeError): #@UndefinedVariable
        h[3] = 5
    with pytest.raises(TypeError): #@UndefinedVariable
        h.add(3, 4)
    with pytest.raises(TypeError): #@UndefinedVariable
        del h[3]
示例#7
0
def test_case_insensitivity():
    h = Headers({'Content-Type': 'text/plain'})
    h.add('Content-Encoding', 'utf8')
    for val in ('content-type', 'content-encoding'):
        assert val.upper() in h
        assert val.lower() in h
        assert val.capitalize() in h
        assert h.get(val.lower()) == h.get(val.upper()) == h.get(
            val.capitalize())
        del h[val.upper()]
        assert val.lower() not in h
示例#8
0
def test_compat_dict():
    h = Headers(D='asdf')
    h.add('E', 'd')
    h.add('E', 'f')
    h.add('Cookie', 'd')
    h.add('Cookie', 'e')
    h.add('Cookie', 'f')
    d = h.compatible_dict()

    for x in ('Cookie', 'D', 'E'):
        assert x in d
    assert d['D'] == 'asdf'
    assert d['E'] == 'd, f'
    assert d['Cookie'] == 'd, e, f'
示例#9
0
def test_compat_dict():
    h = Headers(D='asdf')
    h.add('E', 'd')
    h.add('E', 'f')
    h.add('Cookie', 'd')
    h.add('Cookie', 'e')
    h.add('Cookie', 'f')
    d = h.compatible_dict()

    for x in ('Cookie', 'D', 'E'):
        assert x in d
    assert d['D'] == 'asdf'
    assert d['E'] == 'd, f'
    assert d['Cookie'] == 'd, e, f'
示例#10
0
def test_compat_dict():
    h = Headers(D="asdf")
    h.add("E", "d")
    h.add("E", "f")
    h.add("Cookie", "d")
    h.add("Cookie", "e")
    h.add("Cookie", "f")
    d = h.compatible_dict()

    for x in ("Cookie", "D", "E"):
        assert x in d
    assert d["D"] == "asdf"
    assert d["E"] == "d, f"
    assert d["Cookie"] == "d, e, f"