"""Tests for queues.py""" import unittest import unittest.mock import asyncio from asyncio import test_utils class _QueueTestBase(unittest.TestCase): def setUp(self): self.loop = test_utils.TestLoop() asyncio.set_event_loop(None) def tearDown(self): self.loop.close() class QueueBasicTests(_QueueTestBase): def _test_repr_or_str(self, fn, expect_id): """Test Queue's repr or str. fn is repr or str. expect_id is True if we expect the Queue's id to appear in fn(Queue()). """ def gen(): when = yield self.assertAlmostEqual(0.1, when) when = yield 0.1 self.assertAlmostEqual(0.2, when) yield 0.1 loop = test_utils.TestLoop(gen) self.addCleanup(loop.close) q = asyncio.Queue(loop=loop) self.assertTrue(fn(q).startswith('