summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Hutchinson <jlhutch@gmail.com>2011-07-22 13:46:08 -0500
committerJay Hutchinson <jlhutch@gmail.com>2011-07-22 13:46:08 -0500
commit0b1867a1ef3cd86fe7766957e950909a5d082163 (patch)
tree6be0ae9796c37b815e60eedbb7816f41b74f1991
parent008890860423a9e6a9abff6558c235e9858578f9 (diff)
downloadpylru-0b1867a1ef3cd86fe7766957e950909a5d082163.tar.gz
Improved test code.
-rw-r--r--test.py54
1 files changed, 45 insertions, 9 deletions
diff --git a/test.py b/test.py
index 8edb7a4..fdbabb2 100644
--- a/test.py
+++ b/test.py
@@ -118,40 +118,76 @@ def testcache():
def wraptest():
- def verify(p, q):
- assert p == q
+ def verify(p, x):
+ assert p == x.store
+ for key, value in x.cache.items():
+ assert x.store[key] == value
+
+ tmp = list(x.items())
+ tmp.sort()
+
+ tmp2 = list(p.items())
+ tmp2.sort()
+
+ assert tmp == tmp2
p = dict()
q = dict()
x = lruwrap(q, 128)
- test(p, x, p, q, verify)
+ test(p, x, p, x, verify)
def wraptest2():
- def verify(x, y):
- pass
+ def verify(p, x):
+ for key, value in x.store.items():
+ if key not in x.dirty:
+ assert p[key] == value
+
+ for key in x.dirty:
+ assert x.cache.peek(key) == p[key]
+
+ for key, value in x.cache.items():
+ if key not in x.dirty:
+ assert x.store[key] == p[key] == value
+
+ tmp = list(x.items())
+ tmp.sort()
+
+ tmp2 = list(p.items())
+ tmp2.sort()
+
+ assert tmp == tmp2
p = dict()
q = dict()
x = lruwrap(q, 128, True)
- test(p, x, None, None, verify)
+ test(p, x, p, x, verify)
x.sync()
assert p == q
def wraptest3():
- def verify(x, y):
- pass
+ def verify(p, x):
+ for key, value in x.store.items():
+ if key not in x.dirty:
+ assert p[key] == value
+
+ for key in x.dirty:
+ assert x.cache.peek(key) == p[key]
+
+ for key, value in x.cache.items():
+ if key not in x.dirty:
+ assert x.store[key] == p[key] == value
p = dict()
q = dict()
with lruwrap(q, 128, True) as x:
- test(p, x, None, None, verify)
+ test(p, x, p, x, verify)
assert p == q