def test_finish(self): f = Future() ag = AsyncGroup(partial(f.set_result, True)) self.assertEqual(ag._finished, False) ag.add_notification() ag.finish() self.assertEqual(ag._finished, True) self.assertEqual(f.result(), True)
def test_notifications(self): f = Future() ag = AsyncGroup(partial(f.set_result, True)) not1 = ag.add_notification() not2 = ag.add_notification() self.assertEqual(ag._finished, False) not1() self.assertEqual(ag._finished, False) not2('params', are='ignored') self.assertEqual(ag._finished, True) self.assertEqual(f.result(), True) with ExpectLog(async_logger, r'.*trying to finish already finished AsyncGroup\(name=None, finished=True\)'): ag.finish()
def test_notifications(self): f = Future() ag = AsyncGroup(partial(f.set_result, True)) not1 = ag.add_notification() not2 = ag.add_notification() self.assertEqual(ag._finished, False) not1() self.assertEqual(ag._finished, False) not2('params', are='ignored') self.assertEqual(ag._finished, True) self.assertEqual(f.result(), True) with ExpectLog( async_logger, r'.*trying to finish already finished AsyncGroup\(name=None, finished=True\)' ): ag.finish()