def test_headers_with_dict(): h_rw = rw.headers( rw.number(2), rw.len_prefixed_string(rw.number(2)), rw.len_prefixed_string(rw.number(1)) ) headers = { 'hello': 'world', 'this': 'is a test', } buff = h_rw.write(headers, BytesIO()).getvalue() assert sorted(h_rw.read(bio(buff)), key=lambda x: x[0]) == [ ['hello', 'world'], ['this', 'is a test'] ]
def test_headers(l_rw, k_rw, v_rw, headers, bs): h_rw = rw.headers(l_rw, k_rw, v_rw) assert h_rw.read(bio(bs)) == headers assert h_rw.write(headers, BytesIO()).getvalue() == bytearray(bs) assert h_rw.width() == l_rw.width()