Skip to content

Commit 33e3fcc

Browse files
authored
feat(fixtures): add timeout_secs parameter to create_app_fixture
1 parent d656fdb commit 33e3fcc

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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)