mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Fix asyncio issue 235: Queue subclass bug caused by JoinableQueue merge.
This commit is contained in:
parent
77e8311deb
commit
0bd16bc4cd
3 changed files with 36 additions and 11 deletions
|
@ -408,14 +408,16 @@ class PriorityQueueTests(_QueueTestBase):
|
|||
self.assertEqual([1, 2, 3], items)
|
||||
|
||||
|
||||
class QueueJoinTests(_QueueTestBase):
|
||||
class _QueueJoinTestMixin:
|
||||
|
||||
q_class = None
|
||||
|
||||
def test_task_done_underflow(self):
|
||||
q = asyncio.Queue(loop=self.loop)
|
||||
q = self.q_class(loop=self.loop)
|
||||
self.assertRaises(ValueError, q.task_done)
|
||||
|
||||
def test_task_done(self):
|
||||
q = asyncio.Queue(loop=self.loop)
|
||||
q = self.q_class(loop=self.loop)
|
||||
for i in range(100):
|
||||
q.put_nowait(i)
|
||||
|
||||
|
@ -452,7 +454,7 @@ class QueueJoinTests(_QueueTestBase):
|
|||
self.loop.run_until_complete(asyncio.wait(tasks, loop=self.loop))
|
||||
|
||||
def test_join_empty_queue(self):
|
||||
q = asyncio.Queue(loop=self.loop)
|
||||
q = self.q_class(loop=self.loop)
|
||||
|
||||
# Test that a queue join()s successfully, and before anything else
|
||||
# (done twice for insurance).
|
||||
|
@ -465,12 +467,24 @@ class QueueJoinTests(_QueueTestBase):
|
|||
self.loop.run_until_complete(join())
|
||||
|
||||
def test_format(self):
|
||||
q = asyncio.Queue(loop=self.loop)
|
||||
q = self.q_class(loop=self.loop)
|
||||
self.assertEqual(q._format(), 'maxsize=0')
|
||||
|
||||
q._unfinished_tasks = 2
|
||||
self.assertEqual(q._format(), 'maxsize=0 tasks=2')
|
||||
|
||||
|
||||
class QueueJoinTests(_QueueJoinTestMixin, _QueueTestBase):
|
||||
q_class = asyncio.Queue
|
||||
|
||||
|
||||
class LifoQueueJoinTests(_QueueJoinTestMixin, _QueueTestBase):
|
||||
q_class = asyncio.LifoQueue
|
||||
|
||||
|
||||
class PriorityQueueJoinTests(_QueueJoinTestMixin, _QueueTestBase):
|
||||
q_class = asyncio.PriorityQueue
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue