11import unittest
22from collections import OrderedDict
3- from w3lib .http import basic_auth_header , headers_dict_to_raw , headers_raw_to_dict
3+ from w3lib .http import (
4+ HeadersDictInput ,
5+ basic_auth_header ,
6+ headers_dict_to_raw ,
7+ headers_raw_to_dict ,
8+ )
49
510__doctests__ = ["w3lib.http" ] # for trial support
611
@@ -47,7 +52,9 @@ def test_headers_dict_to_raw(self):
4752 )
4853
4954 def test_headers_dict_to_raw_listtuple (self ):
50- dct = OrderedDict ([(b"Content-type" , [b"text/html" ]), (b"Accept" , [b"gzip" ])])
55+ dct : HeadersDictInput = OrderedDict (
56+ [(b"Content-type" , [b"text/html" ]), (b"Accept" , [b"gzip" ])]
57+ )
5158 self .assertEqual (
5259 headers_dict_to_raw (dct ), b"Content-type: text/html\r \n Accept: gzip"
5360 )
@@ -70,12 +77,13 @@ def test_headers_dict_to_raw_listtuple(self):
7077 )
7178
7279 def test_headers_dict_to_raw_wrong_values (self ):
73- dct = OrderedDict (
80+ dct : HeadersDictInput = OrderedDict (
7481 [
7582 (b"Content-type" , 0 ),
7683 ]
7784 )
7885 self .assertEqual (headers_dict_to_raw (dct ), b"" )
86+ self .assertEqual (headers_dict_to_raw (dct ), b"" )
7987
8088 dct = OrderedDict ([(b"Content-type" , 1 ), (b"Accept" , [b"gzip" ])])
8189 self .assertEqual (headers_dict_to_raw (dct ), b"Accept: gzip" )
0 commit comments