From 33e3fcca33fb4dd06c0aadb2ae854bd67822ac14 Mon Sep 17 00:00:00 2001 From: Evan Glasscock Date: Mon, 14 Jul 2025 16:22:33 -0700 Subject: [PATCH 1/2] feat(fixtures): add timeout_secs parameter to create_app_fixture --- shiny/pytest/_fixture.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/shiny/pytest/_fixture.py b/shiny/pytest/_fixture.py index 385733dd7..61dfe050b 100644 --- a/shiny/pytest/_fixture.py +++ b/shiny/pytest/_fixture.py @@ -36,6 +36,7 @@ def create_app_fixture( app: PurePath | str | list[PurePath | str], scope: ScopeName = "module", + timeout_secs: float = 30, ): """ Create a fixture for a local Shiny app directory. @@ -70,6 +71,8 @@ def create_app_fixture( will be created once per module. See [Pytest fixture scopes](https://docs.pytest.org/en/stable/how-to/fixtures.html#fixture-scopes) for more details. + timeout_secs + The maximum number of seconds to wait for the app to become ready. Returns ------- @@ -133,7 +136,7 @@ def get_app_path(request: pytest.FixtureRequest, app: PurePath | str): @pytest.fixture(scope=scope, params=app) def fixture_func(request: pytest.FixtureRequest): app_path = get_app_path(request, request.param) - sa_gen = shiny_app_gen(app_path) + sa_gen = shiny_app_gen(app_path, timeout_secs=timeout_secs) yield next(sa_gen) else: @@ -142,7 +145,7 @@ def fixture_func(request: pytest.FixtureRequest): @pytest.fixture(scope=scope) def fixture_func(request: pytest.FixtureRequest): app_path = get_app_path(request, app) - sa_gen = shiny_app_gen(app_path) + sa_gen = shiny_app_gen(app_path, timeout_secs=timeout_secs) yield next(sa_gen) return fixture_func From 088d6fc529968c48fcfb1d28e6919d58b7850303 Mon Sep 17 00:00:00 2001 From: Evan Glasscock Date: Tue, 15 Jul 2025 12:33:24 -0700 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c6e3e7d0..a1324948a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * `selectize`, `remove_button`, and `options` parameters of `ui.input_select()` have been deprecated; use `ui.input_selectize()` instead. (Thanks, @ErdaradunGaztea!) (#1947) +* Added `timeout_secs` parameter to `create_app_fixture` to allow testing apps with longer startup times. (#2033) + ### Bug fixes * Fixed an issue with `ui.Chat()` sometimes wanting to scroll a parent element. (#1996)