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')
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')
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')
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')