Skip to content

Commit 37216a2

Browse files
committed
Try to yield the generator directly
1 parent b3e0fe0 commit 37216a2

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

shiny/pytest/_fixture.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,25 +121,28 @@ def test_more_app_code(page: Page, app: ShinyAppProc):
121121
```
122122
"""
123123

124-
def yield_app(app: PurePath | str):
124+
def get_app_path(app: PurePath | str):
125125
app_purepath_exists = isinstance(app, PurePath) and Path(app).is_file()
126126
app_path = app if app_purepath_exists else Path(app)
127-
sa_gen = shiny_app_gen(app_path)
128-
yield next(sa_gen)
127+
return app_path
129128

130129
if isinstance(app, list):
131130

132131
# Multiple app values provided
133132
# Will display the app value as a parameter in the logs
134133
@pytest.fixture(scope=scope, params=app)
135134
def fixture_func(request: pytest.FixtureRequest):
136-
yield yield_app(request.param)
135+
app_path = get_app_path(request.param)
136+
sa_gen = shiny_app_gen(app_path)
137+
yield next(sa_gen)
137138

138139
else:
139140
# Single app value provided
140141
# No indication of the app value in the logs
141142
@pytest.fixture(scope=scope)
142143
def fixture_func(request: pytest.FixtureRequest):
143-
yield yield_app(app)
144+
app_path = get_app_path(app)
145+
sa_gen = shiny_app_gen(app_path)
146+
yield next(sa_gen)
144147

145148
return fixture_func

0 commit comments

Comments
 (0)