Coding style.
Moved the Result class into tools, which simplifies worker.py and makes the circular import problem go away.
This commit is contained in:
parent
cc95534bd7
commit
2373e78cbd
5 changed files with 151 additions and 149 deletions
|
|
@ -188,5 +188,28 @@ class ToolsTestCase(unittest.TestCase):
|
|||
self._test_tool(tools.php5_syntax, [("root.php", tools.Status.ok)])
|
||||
|
||||
|
||||
class LruCacheWithEvictionTestCase(unittest.TestCase):
|
||||
|
||||
def _assert_cache(self, func, hits, misses, current_size):
|
||||
cache_info = func.cache_info()
|
||||
self.assertEqual(cache_info.hits, hits)
|
||||
self.assertEqual(cache_info.misses, misses)
|
||||
self.assertEqual(cache_info.currsize, current_size)
|
||||
|
||||
def test_lru_cache_with_eviction(self):
|
||||
@tools.lru_cache_with_eviction()
|
||||
def a(foo):
|
||||
return foo
|
||||
self._assert_cache(a, 0, 0, 0)
|
||||
self.assertEqual(a(1), 1)
|
||||
self._assert_cache(a, 0, 1, 1)
|
||||
a(1)
|
||||
self._assert_cache(a, 1, 1, 1)
|
||||
a.evict(1)
|
||||
self._assert_cache(a, 1, 1, 1)
|
||||
a(1)
|
||||
self._assert_cache(a, 1, 2, 2)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
golden.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue