From 21569b3a31499328a8fd68a23f9fe82988e7aa55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 29 Jul 2019 19:58:43 +0200 Subject: [PATCH] tests: fix events tests on python3.7 Fix syntax workaround for python3.7 + python2.7. This code can't use 'yield from' to be still importable on python2.7, but asyncio.sleep() is no longer iterable on python3.7. Workaround it by manually calling coroutine.send(None) in a loop - ugly as hell, but works. I can't wait until we could drop python2 support... --- qubesadmin/tests/events.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qubesadmin/tests/events.py b/qubesadmin/tests/events.py index 54984bb..fca6648 100644 --- a/qubesadmin/tests/events.py +++ b/qubesadmin/tests/events.py @@ -107,7 +107,8 @@ class TC_00_Events(qubesadmin.tests.QubesTestCase): for event in events: stream.feed_data(event) # don't use yield from... - for x in asyncio.sleep(0.01): + sleep = asyncio.sleep(0.01) + for x in iter(lambda: sleep.send(None), None): yield x stream.feed_eof()