コード例 #1
0
 async def test_get_before_put(self):
     channel = AsyncChannel()
     get, put = await asyncio.gather(
             anext(channel),
             momentarily(1, channel.put('foo')))
     self.assertIsNone(put)
     self.assertEqual(get, 'foo')
コード例 #2
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')
コード例 #3
0
    async def test_close_with_pending_get(self):
        channel = AsyncChannel()
        with self.assertRaises(StopAsyncIteration):
            get, close = await asyncio.gather(anext(channel),
                                              momentarily(1, channel.close()))

        with self.assertRaises(StopAsyncIteration):
            await anext(channel)
        with self.assertRaises(ValueError):
            await channel.put('foo')
コード例 #4
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')
コード例 #5
0
    async def test_close_with_pending_get(self):
        channel = AsyncChannel()
        with self.assertRaises(StopAsyncIteration):
            get, close = await asyncio.gather(
                    anext(channel),
                    momentarily(1, channel.close()))

        with self.assertRaises(StopAsyncIteration):
            await anext(channel)
        with self.assertRaises(ValueError):
            await channel.put('foo')
コード例 #6
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')
コード例 #7
0
    async def test_close_with_pending_put(self):
        channel = AsyncChannel()
        put, close, get = await asyncio.gather(channel.put('foo'),
                                               momentarily(1, channel.close()),
                                               momentarily(2, anext(channel)))
        self.assertIsNone(put)
        self.assertIsNone(close)
        self.assertEqual(get, 'foo')

        with self.assertRaises(StopAsyncIteration):
            await anext(channel)
        with self.assertRaises(ValueError):
            await channel.put('foo')
コード例 #8
0
    async def test_close_with_pending_put(self):
        channel = AsyncChannel()
        put, close, get = await asyncio.gather(
                channel.put('foo'),
                momentarily(1, channel.close()),
                momentarily(2, anext(channel)))
        self.assertIsNone(put)
        self.assertIsNone(close)
        self.assertEqual(get, 'foo')

        with self.assertRaises(StopAsyncIteration):
            await anext(channel)
        with self.assertRaises(ValueError):
            await channel.put('foo')
コード例 #9
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')
コード例 #10
0
 async def test_get_before_put(self):
     channel = AsyncChannel()
     get, put = await asyncio.gather(anext(channel),
                                     momentarily(1, channel.put('foo')))
     self.assertIsNone(put)
     self.assertEqual(get, 'foo')