From 6877c6ca06ef605e1227b79092cf8054996df27a Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Wed, 13 Jan 2016 20:51:39 -0500 Subject: [PATCH] Fix flaky multiplex test. Signed-off-by: Daniel Nephin --- tests/unit/multiplexer_test.py | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/tests/unit/multiplexer_test.py b/tests/unit/multiplexer_test.py index 750faad88..737ba25d6 100644 --- a/tests/unit/multiplexer_test.py +++ b/tests/unit/multiplexer_test.py @@ -49,18 +49,13 @@ class MultiplexerTest(unittest.TestCase): list(mux.loop()) def test_cascade_stop(self): - mux = Multiplexer([ - ((lambda x: sleep(0.01) or x)(x) for x in ['after 0.01 sec T1', - 'after 0.02 sec T1', - 'after 0.03 sec T1']), - ((lambda x: sleep(0.02) or x)(x) for x in ['after 0.02 sec T2', - 'after 0.04 sec T2', - 'after 0.06 sec T2']), - ], cascade_stop=True) + def fast_stream(): + for num in range(3): + yield "stream1 %s" % num - self.assertEqual( - ['after 0.01 sec T1', - 'after 0.02 sec T1', - 'after 0.02 sec T2', - 'after 0.03 sec T1'], - sorted(list(mux.loop()))) + def slow_stream(): + sleep(5) + yield "stream2 FAIL" + + mux = Multiplexer([fast_stream(), slow_stream()], cascade_stop=True) + assert "stream2 FAIL" not in set(mux.loop())