File tree Expand file tree Collapse file tree 1 file changed +49
-1
lines changed
Expand file tree Collapse file tree 1 file changed +49
-1
lines changed Original file line number Diff line number Diff line change 1212import h2 .errors
1313import h2 .events
1414import h2 .exceptions
15- from h2 .utilities import extract_method_header
15+ from h2 .utilities import SizeLimitDict , extract_method_header
1616
1717# These tests require a non-list-returning range function.
1818try :
@@ -176,3 +176,51 @@ class TestExtractHeader(object):
176176 )
177177 def test_extract_header_method (self , headers ):
178178 assert extract_method_header (headers ) == b'GET'
179+
180+
181+ def test_size_limit_dict_limit ():
182+ dct = SizeLimitDict (size_limit = 2 )
183+
184+ dct [1 ] = 1
185+ dct [2 ] = 2
186+
187+ assert len (dct ) == 2
188+ assert dct [1 ] == 1
189+ assert dct [2 ] == 2
190+
191+ dct [3 ] = 3
192+
193+ assert len (dct ) == 2
194+ assert dct [2 ] == 2
195+ assert dct [3 ] == 3
196+ assert 1 not in dct
197+
198+
199+ def test_size_limit_dict_limit_init ():
200+ initial_dct = {
201+ 1 : 1 ,
202+ 2 : 2 ,
203+ 3 : 3 ,
204+ }
205+
206+ dct = SizeLimitDict (initial_dct , size_limit = 2 )
207+
208+ assert len (dct ) == 2
209+
210+
211+ def test_size_limit_dict_no_limit ():
212+ dct = SizeLimitDict (size_limit = None )
213+
214+ dct [1 ] = 1
215+ dct [2 ] = 2
216+
217+ assert len (dct ) == 2
218+ assert dct [1 ] == 1
219+ assert dct [2 ] == 2
220+
221+ dct [3 ] = 3
222+
223+ assert len (dct ) == 3
224+ assert dct [1 ] == 1
225+ assert dct [2 ] == 2
226+ assert dct [3 ] == 3
You can’t perform that action at this time.
0 commit comments