MCPcopy Create free account
hub / github.com/ScalingIntelligence/tokasaurus / test_basic_free

Function test_basic_free

tests/test_block_allocator.py:84–118  ·  view source on GitHub ↗
(allocator: BlockAllocator)

Source from the content-addressed store, hash-verified

82
83
84def test_basic_free(allocator: BlockAllocator):
85 allocator.sanity_checks()
86
87 input_ids1 = [1] * 31
88 input_ids2 = [2] * 31
89 input_ids3 = [3] * 31
90
91 completion_ids1 = input_ids1 + [1]
92 completion_ids2 = input_ids2 + [2]
93
94 kvs1, num_cached1 = allocator.allocate_with_prefix_match("seq1", input_ids1)
95 allocator.sanity_checks()
96
97 with pytest.raises(ValueError):
98 allocator.allocate_with_prefix_match("seq2", input_ids2)
99
100 kvs1.extend(allocator.allocate_up_to_length("seq1", kvs1, len(completion_ids1)))
101 allocator.sanity_checks()
102 allocator.free_and_update("seq1", kvs1, completion_ids1)
103 allocator.sanity_checks()
104
105 kvs2, num_cached2 = allocator.allocate_with_prefix_match("seq2", input_ids2)
106 allocator.sanity_checks()
107
108 assert num_cached2 == 0
109
110 kvs2.extend(allocator.allocate_up_to_length("seq2", kvs2, len(completion_ids2)))
111 allocator.sanity_checks()
112 allocator.free_and_update("seq2", kvs2, completion_ids2)
113 allocator.sanity_checks()
114
115 kvs3, num_cached3 = allocator.allocate_with_prefix_match("seq3", input_ids3)
116 allocator.sanity_checks()
117
118 assert num_cached3 == 0
119
120
121def test_multi_branch_free(allocator: BlockAllocator):

Callers

nothing calls this directly

Calls 4

sanity_checksMethod · 0.80
allocate_up_to_lengthMethod · 0.80
free_and_updateMethod · 0.80

Tested by

no test coverage detected