Example #1
0
 def test_ShortCircuit(self):
     """Test that creation short-circuits to reuse existing references"""
     sd = {}
     for s in self.ss:
         sd[s] = 1
     for t in self.ts:
         if hasattr(t, 'x'):
             assert safe_ref(t.x) in sd
         else:
             assert safe_ref(t) in sd
Example #2
0
 def setUp(self):
     ts = []
     ss = []
     for x in range(100):
         t = _Sample1()
         ts.append(t)
         s = safe_ref(t.x, self._closure)
         ss.append(s)
     ts.append(_sample2)
     ss.append(safe_ref(_sample2, self._closure))
     for x in range(30):
         t = _Sample3()
         ts.append(t)
         s = safe_ref(t, self._closure)
         ss.append(s)
     self.ts = ts
     self.ss = ss
     self.closure_count = 0
Example #3
0
 def test_In(self):
     """Test the `in` operator for safe references (cmp)"""
     for t in self.ts[:50]:
         assert safe_ref(t.x) in self.ss