1
1
import unittest
2
2
from 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
+ )
4
9
5
10
__doctests__ = ["w3lib.http" ] # for trial support
6
11
@@ -47,7 +52,9 @@ def test_headers_dict_to_raw(self):
47
52
)
48
53
49
54
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
+ )
51
58
self .assertEqual (
52
59
headers_dict_to_raw (dct ), b"Content-type: text/html\r \n Accept: gzip"
53
60
)
@@ -70,12 +77,13 @@ def test_headers_dict_to_raw_listtuple(self):
70
77
)
71
78
72
79
def test_headers_dict_to_raw_wrong_values (self ):
73
- dct = OrderedDict (
80
+ dct : HeadersDictInput = OrderedDict (
74
81
[
75
82
(b"Content-type" , 0 ),
76
83
]
77
84
)
78
85
self .assertEqual (headers_dict_to_raw (dct ), b"" )
86
+ self .assertEqual (headers_dict_to_raw (dct ), b"" )
79
87
80
88
dct = OrderedDict ([(b"Content-type" , 1 ), (b"Accept" , [b"gzip" ])])
81
89
self .assertEqual (headers_dict_to_raw (dct ), b"Accept: gzip" )
0 commit comments