Exemple #1
0
    async def test_abort_with_pending_get(self):
        channel = AsyncChannel()
        with self.assertRaises(MadeUpError):
            get, abort = await asyncio.gather(
                anext(channel), momentarily(1, channel.abort(MadeUpError())))

        with self.assertRaises(MadeUpError):
            await anext(channel)
        with self.assertRaises(ValueError):
            await channel.put('foo')
    async def test_abort_with_pending_get(self):
        channel = AsyncChannel()
        with self.assertRaises(MadeUpError):
            get, abort = await asyncio.gather(
                    anext(channel),
                    momentarily(1, channel.abort(MadeUpError())))

        with self.assertRaises(MadeUpError):
            await anext(channel)
        with self.assertRaises(ValueError):
            await channel.put('foo')
Exemple #3
0
    async def test_abort_with_pending_put(self):
        channel = AsyncChannel()
        put, abort, get = await asyncio.gather(
            channel.put('foo'), momentarily(1, channel.abort(MadeUpError())),
            momentarily(2, anext(channel)))
        self.assertIsNone(put)
        self.assertIsNone(abort)
        self.assertEqual(get, 'foo')

        with self.assertRaises(MadeUpError):
            await anext(channel)
        with self.assertRaises(ValueError):
            await channel.put('foo')
    async def test_abort_with_pending_put(self):
        channel = AsyncChannel()
        put, abort, get = await asyncio.gather(
                channel.put('foo'),
                momentarily(1, channel.abort(MadeUpError())),
                momentarily(2, anext(channel)))
        self.assertIsNone(put)
        self.assertIsNone(abort)
        self.assertEqual(get, 'foo')

        with self.assertRaises(MadeUpError):
            await anext(channel)
        with self.assertRaises(ValueError):
            await channel.put('foo')