Exemple #1
0
    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)
Exemple #2
0
    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)
Exemple #3
0
    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()
Exemple #4
0
    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()