MCPcopy
hub / github.com/msiemens/tinydb / test_lru_cache

Function test_lru_cache

tests/test_tables.py:122–139  ·  view source on GitHub ↗
(db)

Source from the content-addressed store, hash-verified

120
121
122def test_lru_cache(db):
123 # Test integration into TinyDB
124 table = db.table('table3', cache_size=2)
125 query = where('int') == 1
126
127 table.search(query)
128 table.search(where('int') == 2)
129 table.search(where('int') == 3)
130 assert query not in table._query_cache
131
132 table.remove(where('int') == 1)
133 assert not table._query_cache.lru
134
135 table.search(query)
136
137 assert len(table._query_cache) == 1
138 table.clear_cache()
139 assert len(table._query_cache) == 0
140
141
142def test_table_is_iterable(db):

Callers

nothing calls this directly

Calls 5

whereFunction · 0.90
tableMethod · 0.80
removeMethod · 0.80
clear_cacheMethod · 0.80
searchMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…