Permalink
Browse files

Fix duh moment in handling pairs, add more tests

  • Loading branch information...
1 parent 5df8238 commit 5775c08a230ef04e68544f7ff6887d36f9e8c472 @harryf committed Feb 12, 2009
Showing with 54 additions and 0 deletions.
  1. +54 −0 dammit/nullcache.py
View
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+For tests - a cache which doesn't remember
+anything
+"""
+from cachemanager import namespacer
+
+class NullCache(object):
+ """
+ >>> nc = NullCache()
+ >>> 'foo' in nc
+ False
+ >>> nc['foo'] = 'bar'
+ >>> 'foo' in nc
+ False
+ >>> nc['foo'] == 'bar'
+ Traceback (most recent call last):
+ KeyError: '_foo'
+ >>> del nc['foo']
+ Traceback (most recent call last):
+ KeyError: '_foo'
+ """
+ def __init__(self):
+ self.namespace = ''
+
+ def __len__(self):
+ raise Exception("Not implemented")
+
+ @namespacer
+ def __contains__(self, key):
+ return False
+
+ @namespacer
+ def __setitem__(self, key, val):
+ pass
+
+ @namespacer
+ def __getitem__(self, key):
+ raise KeyError(key)
+
+ @namespacer
+ def __delitem__(self, key):
+ raise KeyError(key)
+
+ def __repr__(self):
+ return "NullCache"
+
+def _test():
+ import doctest
+ doctest.testmod()
+
+if __name__ == '__main__':
+ _test()

0 comments on commit 5775c08

Please sign in to comment.