Exemple #1
0
 def testShortCircuit(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'):
             self.assertIn(safe_ref(t.x), sd)
         else:
             self.assertIn(safe_ref(t), sd)
Exemple #2
0
 def testShortCircuit(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'):
             self.assertIn(safe_ref(t.x), sd)
         else:
             self.assertIn(safe_ref(t), sd)
Exemple #3
0
 def setUp(self):
     super(TestSaferef, self).setUp()
     ts = []
     ss = []
     for x in range(5000):
         t = Class1()
         ts.append(t)
         s = safe_ref(t.x, self._closure)
         ss.append(s)
     ts.append(fun)
     ss.append(safe_ref(fun, self._closure))
     for x in range(30):
         t = Class2()
         ts.append(t)
         s = safe_ref(t, self._closure)
         ss.append(s)
     self.ts = ts
     self.ss = ss
     self.closureCount = 0
Exemple #4
0
 def setUp(self):
     super(TestSaferef, self).setUp()
     ts = []
     ss = []
     for x in range(5000):
         t = Class1()
         ts.append(t)
         s = safe_ref(t.x, self._closure)
         ss.append(s)
     ts.append(fun)
     ss.append(safe_ref(fun, self._closure))
     for x in range(30):
         t = Class2()
         ts.append(t)
         s = safe_ref(t, self._closure)
         ss.append(s)
     self.ts = ts
     self.ss = ss
     self.closureCount = 0
Exemple #5
0
 def testIn(self):
     """Test the "in" operator for safe references (cmp)"""
     for t in self.ts[:50]:
         self.assertTrue(safe_ref(t.x) in self.ss)
Exemple #6
0
 def testIn(self):
     """Test the "in" operator for safe references (cmp)"""
     for t in self.ts[:50]:
         self.assertTrue(safe_ref(t.x) in self.ss)