diff --git a/qtrio/_pytest.py b/qtrio/_pytest.py index 0f06d541..73ce84b5 100644 --- a/qtrio/_pytest.py +++ b/qtrio/_pytest.py @@ -29,40 +29,18 @@ def host(test_function: typing.Callable[..., typing.Awaitable[None]]): test_function: The pytest function to be tested. """ - @pytest.mark.usefixtures("qapp", "qtbot") + @pytest.mark.usefixtures("qapp") @functools.wraps(test_function) def wrapper(*args, **kwargs): request = kwargs["request"] qapp = request.getfixturevalue("qapp") - qtbot = request.getfixturevalue("qtbot") - - test_outcomes_sentinel = qtrio.Outcomes( - qt=outcome.Value(0), trio=outcome.Value(29), - ) - test_outcomes = test_outcomes_sentinel - - def done_callback(outcomes): - nonlocal test_outcomes - test_outcomes = outcomes - - runner = qtrio._core.Runner( - application=qapp, - done_callback=done_callback, - quit_application=False, - timeout=timeout, - ) - - runner.run( - functools.partial(test_function, **kwargs), - *args, - execute_application=False, - ) - - # TODO: probably increases runtime of fast tests a lot due to polling - qtbot.wait_until( - lambda: test_outcomes is not test_outcomes_sentinel, timeout=3.14e8 - ) + + runner = qtrio._core.Runner(application=qapp, timeout=timeout) + + async_fn = functools.partial(test_function, *args, **kwargs) + test_outcomes = runner.run(async_fn=async_fn) + test_outcomes.unwrap() return wrapper