Пример #1
0
def test_headers_items():
    headers = [XHeader(name='A', value='a'), XHeader(name='B', value='b')]
    h = SpamcHeaders(headers=headers)
    header_tuples = [(header.field_name(), header) for header in headers]

    for test_result in h.items():
        assert test_result in header_tuples
Пример #2
0
def test_headers_items():
    headers = {
        'A': GenericHeaderValue(value='a'),
        'B': GenericHeaderValue(value='b')
    }
    h = SpamcHeaders(headers=headers)

    for test_key, test_value in h.items():
        assert test_key in headers
        assert headers[test_key] is test_value
Пример #3
0
def test_headers_bytes():
    h = SpamcHeaders(headers={
        'A': GenericHeaderValue(value='a'),
        'B': GenericHeaderValue(value='b')
    })
    result = bytes(h)

    header_bytes = [
        b'%b: %b\r\n' % (name.encode('ascii'), bytes(value))
        for name, value in h.items()
    ]
    for header in header_bytes:
        assert header in result