1
from django.dispatch.saferef import *
13
def __call__(self, obj):
16
class Tester(unittest.TestCase):
20
for x in xrange(5000):
23
s = safeRef(t.x, self._closure)
26
ss.append(safeRef(test2, self._closure))
30
s = safeRef(t, self._closure)
41
"""Test the "in" operator for safe references (cmp)"""
42
for t in self.ts[:50]:
43
self.assert_(safeRef(t.x) in self.ss)
46
"""Test that the references are valid (return instance methods)"""
50
def testShortCircuit (self):
51
"""Test that creation short-circuits to reuse existing references"""
57
self.assert_(sd.has_key(safeRef(t.x)))
58
self.assert_(safeRef(t.x) in sd)
60
self.assert_(sd.has_key(safeRef(t)))
61
self.assert_(safeRef(t) in sd)
63
def testRepresentation (self):
64
"""Test that the reference object's representation works
66
XXX Doesn't currently check the results, just that no error
71
def _closure(self, ref):
72
"""Dumb utility mechanism to increment deletion counter"""
76
return unittest.makeSuite(Tester,'test')
78
if __name__ == "__main__":