Exemplo n.º 1
0
 def test_value_passing_when_fnc(self):
     def fnc():
         return 52
     block = CoroutineBlock(fnc())
     block.process()
     self.assertTrue(block.delivered)
     self.assertEqual(block.value, 52)
Exemplo n.º 2
0
    def test_block_parking(self):
        def fnc():
            yield Promise()
            yield Promise()

        block = CoroutineBlock(fnc())
        self.assertFalse(block.parked)
        block.process()
        self.assertTrue(block.parked)
        block._last_promise.delivery(True)
        self.assertFalse(block.parked)
Exemplo n.º 3
0
    def test_values_passing_when_generator(self):
        def fnc():
            val = yield Promise()
            self.assertEqual(val, 50)
            return 12

        block = CoroutineBlock(fnc())
        block.process()
        block._last_promise.delivery(50)
        block.process()
        self.assertTrue(block.delivered)
        self.assertEqual(block.value, 12)