def test_get_closed(self): # Verify that the .get() method errbacks when the queue is closed. q = ClosableDeferredQueue() q.closed = RuntimeError("testing") d = self.assertFailure(q.get(), RuntimeError) d.addCallback(lambda e: self.assertEqual(e.args[0], "testing")) return d
def test_close_waiting(self): # Verify that the deferred waiting for new data are errbacked when the # queue is closed. q = ClosableDeferredQueue() d = q.get() q.close(RuntimeError("testing")) self.assertTrue(q.closed) self.assertEqual(q.waiting, []) self.assertEqual(q.pending, []) return self.assertFailure(d, RuntimeError)