-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcache_tests.py
More file actions
46 lines (40 loc) · 908 Bytes
/
Copy pathcache_tests.py
File metadata and controls
46 lines (40 loc) · 908 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/python
#
# Unit tests for cs.cache.
# - Cameron Simpson <cs@cskk.id.au> 04aug2014
#
from __future__ import print_function
import sys
import os
import os.path
import errno
from threading import Lock
import time
import unittest
from .cache import LRU_Cache
def check(o):
return o._selfcheck()
class Test_LRU_Cache(unittest.TestCase):
''' Test `cs.cache.LRU_Cache`.
'''
def test_setup(self):
self.assertRaises(ValueError, LRU_Cache, maxsize=0)
C = LRU_Cache(maxsize=2)
check(C)
self.assertEqual(C, {})
C[1] = 2
self.assertEqual(C, {1: 2})
check(C)
C[3] = 4
self.assertEqual(C, {1: 2, 3: 4})
check(C)
C[5] = 6
self.assertEqual(C, {3: 4, 5: 6})
check(C)
C.flush()
self.assertEqual(C, {})
check(C)
def selftest(argv):
unittest.main(__name__, None, argv, failfast=True)
if __name__ == '__main__':
selftest(sys.argv)