Browse Source

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...
Marek Marczykowski-Górecki 4 years ago
parent
commit
21569b3a31
1 changed files with 2 additions and 1 deletions
  1. 2 1
      qubesadmin/tests/events.py

+ 2 - 1
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()