diff --git a/kivy/tests/async_common.py b/kivy/tests/async_common.py index 6578a4c3d..97dab7df0 100644 --- a/kivy/tests/async_common.py +++ b/kivy/tests/async_common.py @@ -154,8 +154,6 @@ class UnitKivyApp(object): def __init__(self, **kwargs): super().__init__(**kwargs) - from kivy.clock import Clock - self.async_sleep = Clock._async_lib.sleep def started_app(*largs): self.app_has_started = True @@ -165,11 +163,14 @@ class UnitKivyApp(object): self.app_has_stopped = True self.fbind('on_stop', stopped_app) - async def async_run(self, async_lib=None): + def set_async_lib(self, async_lib): from kivy.clock import Clock if async_lib is not None: Clock.init_async_lib(async_lib) self.async_sleep = Clock._async_lib.sleep + + async def async_run(self, async_lib=None): + self.set_async_lib(async_lib) return await super(UnitKivyApp, self).async_run(async_lib=async_lib) def resolve_widget(self, base_widget=None): diff --git a/kivy/tests/fixtures.py b/kivy/tests/fixtures.py index f2b9127f3..a473df0d6 100644 --- a/kivy/tests/fixtures.py +++ b/kivy/tests/fixtures.py @@ -73,6 +73,7 @@ async def kivy_app(request, nursery): Window.canvas.clear() app = request.param[0]() + app.set_async_lib(async_lib) if async_lib == 'asyncio': import asyncio @@ -80,6 +81,8 @@ async def kivy_app(request, nursery): loop.create_task(app.async_run()) else: nursery.start_soon(app.async_run) + from kivy.clock import Clock + Clock._max_fps = 0 ts = time.perf_counter() while not app.app_has_started: