Skip to content

Commit 8ca6d08

Browse files
committed
Test coverage 100%
1 parent db6f0c0 commit 8ca6d08

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

test/test_utility_functions.py

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import h2.errors
1313
import h2.events
1414
import 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.
1818
try:
@@ -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

0 commit comments

Comments
 (0)