Skip to content

Commit 3055517

Browse files
authored
feat(fixtures): add timeout_secs parameter to create_app_fixture (#2033)
1 parent 461f77d commit 3055517

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2121

2222
* `selectize`, `remove_button`, and `options` parameters of `ui.input_select()` have been deprecated; use `ui.input_selectize()` instead. (Thanks, @ErdaradunGaztea!) (#1947)
2323

24+
* Added `timeout_secs` parameter to `create_app_fixture` to allow testing apps with longer startup times. (#2033)
25+
2426
### Bug fixes
2527

2628
* Fixed an issue with `ui.Chat()` sometimes wanting to scroll a parent element. (#1996)

shiny/pytest/_fixture.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
def create_app_fixture(
3737
app: PurePath | str | list[PurePath | str],
3838
scope: ScopeName = "module",
39+
timeout_secs: float = 30,
3940
):
4041
"""
4142
Create a fixture for a local Shiny app directory.
@@ -70,6 +71,8 @@ def create_app_fixture(
7071
will be created once per module. See [Pytest fixture
7172
scopes](https://docs.pytest.org/en/stable/how-to/fixtures.html#fixture-scopes)
7273
for more details.
74+
timeout_secs
75+
The maximum number of seconds to wait for the app to become ready.
7376
7477
Returns
7578
-------
@@ -133,7 +136,7 @@ def get_app_path(request: pytest.FixtureRequest, app: PurePath | str):
133136
@pytest.fixture(scope=scope, params=app)
134137
def fixture_func(request: pytest.FixtureRequest):
135138
app_path = get_app_path(request, request.param)
136-
sa_gen = shiny_app_gen(app_path)
139+
sa_gen = shiny_app_gen(app_path, timeout_secs=timeout_secs)
137140
yield next(sa_gen)
138141

139142
else:
@@ -142,7 +145,7 @@ def fixture_func(request: pytest.FixtureRequest):
142145
@pytest.fixture(scope=scope)
143146
def fixture_func(request: pytest.FixtureRequest):
144147
app_path = get_app_path(request, app)
145-
sa_gen = shiny_app_gen(app_path)
148+
sa_gen = shiny_app_gen(app_path, timeout_secs=timeout_secs)
146149
yield next(sa_gen)
147150

148151
return fixture_func

0 commit comments

Comments
 (0)