Mercurial > hg
comparison tests/test-lrucachedict.py @ 39564:5d75a3c16193
util: make capacity a public attribute on lrucachedict
So others can query it. Useful for operations that may want to verify
the cache has capacity for N items before it performs an operation that
may cause cache eviction.
Differential Revision: https://phab.mercurial-scm.org/D4499
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 06 Sep 2018 11:37:27 -0700 |
parents | b31b01f93b11 |
children | 2dcc68c7d25b |
comparison
equal
deleted
inserted
replaced
39563:b31b01f93b11 | 39564:5d75a3c16193 |
---|---|
9 ) | 9 ) |
10 | 10 |
11 class testlrucachedict(unittest.TestCase): | 11 class testlrucachedict(unittest.TestCase): |
12 def testsimple(self): | 12 def testsimple(self): |
13 d = util.lrucachedict(4) | 13 d = util.lrucachedict(4) |
14 self.assertEqual(d.capacity, 4) | |
14 d['a'] = 'va' | 15 d['a'] = 'va' |
15 d['b'] = 'vb' | 16 d['b'] = 'vb' |
16 d['c'] = 'vc' | 17 d['c'] = 'vc' |
17 d['d'] = 'vd' | 18 d['d'] = 'vd' |
18 | 19 |