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) 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