From 77c69f661d27f828fbb1f9f8891c0ff66c4c355e Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Wed, 8 May 2019 23:01:18 -0300 Subject: [PATCH] add locking cases scenarios --- tests/unit/dht/protocol/test_async_gen_junction.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/unit/dht/protocol/test_async_gen_junction.py b/tests/unit/dht/protocol/test_async_gen_junction.py index 1d2b97718..5dd9c8f29 100644 --- a/tests/unit/dht/protocol/test_async_gen_junction.py +++ b/tests/unit/dht/protocol/test_async_gen_junction.py @@ -17,10 +17,10 @@ class MockAsyncGen: return self async def __anext__(self): + await asyncio.sleep(self.delay, loop=self.loop) if self.count > self.stop_cnt - 1: raise StopAsyncIteration() self.count += 1 - await asyncio.sleep(self.delay, loop=self.loop) return self.result async def aclose(self): @@ -48,6 +48,18 @@ class TestAsyncGeneratorJunction(AsyncioTestCase): self.assertEqual(fast_gen.called_close, True) self.assertEqual(slow_gen.called_close, True) + async def test_nothing_to_yield(self): + async def __nothing(): + for _ in []: + yield self.fail("nada") + await self._test_junction([], __nothing()) + + async def test_fast_iteratiors(self): + async def __gotta_go_fast(): + for _ in range(10): + yield 0 + await self._test_junction([0]*40, __gotta_go_fast(), __gotta_go_fast(), __gotta_go_fast(), __gotta_go_fast()) + @unittest.SkipTest async def test_one_stopped_first(self): expected_order = [1, 2, 1, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2]