def test_stopall(self): stoppablemanager = StoppableManager.getinstance() stoppablemanager._reset() s1 = _StoppableTestObject() s2 = _StoppableTestObject() self.assertFalse(s1.callback.delivered) self.assertFalse(s2.callback.delivered) stoppablemanager._removestoppable(s2) StoppableManager.stopall() self.assertTrue(s1.callback.delivered) self.assertFalse(s2.callback.delivered) stoppablemanager._stopall()
def test_stale_weakref(self): stoppablemanager = StoppableManager.getinstance() stoppablemanager._reset() s1 = _StoppableTestObject() s2 = _NotInitializedStoppableTestObject() ref = weakref.ref(s2) # no callback stoppablemanager._stoppables.append(ref) c2 = s2.callback self.assertFalse(s1.callback.delivered) self.assertFalse(s2.callback.delivered) del s2 s2 = None StoppableManager.stopall() self.assertTrue(s1.callback.delivered) self.assertFalse(c2.delivered)
def test_removestoppable_unknown(self): stoppablemanager = StoppableManager.getinstance() stoppablemanager._reset() s1 = _NotStoppableTestObject() stoppablemanager._removestoppable(s1)