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
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
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