From 2cdc92fc04aa0f45115cf5f69d04d83a92ed2ef6 Mon Sep 17 00:00:00 2001 From: laike9m Date: Tue, 17 Jan 2017 23:18:53 +0800 Subject: [PATCH] Fix test_adapter_received_values and test_adapter_sending_values for Python 3 --- hyper/http20/util.py | 6 +++--- test/test_hyper.py | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/hyper/http20/util.py b/hyper/http20/util.py index b116d095..ca5547d0 100644 --- a/hyper/http20/util.py +++ b/hyper/http20/util.py @@ -52,9 +52,9 @@ def h2_safe_headers(headers): """ stripped = { i.lower().strip() - for k, v in headers if k == 'connection' - for i in v.split(',') + for k, v in headers if k == b'connection' + for i in v.split(b',') } - stripped.add('connection') + stripped.add(b'connection') return [header for header in headers if header[0] not in stripped] diff --git a/test/test_hyper.py b/test/test_hyper.py index 59d354c7..6a18d592 100644 --- a/test/test_hyper.py +++ b/test/test_hyper.py @@ -1176,27 +1176,27 @@ def test_nghttp2_installs_correctly(self): assert True def test_stripping_connection_header(self): - headers = [('one', 'two'), ('connection', 'close')] - stripped = [('one', 'two')] + headers = [(b'one', b'two'), (b'connection', b'close')] + stripped = [(b'one', b'two')] assert h2_safe_headers(headers) == stripped def test_stripping_related_headers(self): headers = [ - ('one', 'two'), ('three', 'four'), ('five', 'six'), - ('connection', 'close, three, five') + (b'one', b'two'), (b'three', b'four'), (b'five', b'six'), + (b'connection', b'close, three, five') ] - stripped = [('one', 'two')] + stripped = [(b'one', b'two')] assert h2_safe_headers(headers) == stripped def test_stripping_multiple_connection_headers(self): headers = [ - ('one', 'two'), ('three', 'four'), ('five', 'six'), - ('connection', 'close'), - ('connection', 'three, five') + (b'one', b'two'), (b'three', b'four'), (b'five', b'six'), + (b'connection', b'close'), + (b'connection', b'three, five') ] - stripped = [('one', 'two')] + stripped = [(b'one', b'two')] assert h2_safe_headers(headers) == stripped