Skip to content

Commit 51da1cc

Browse files
authored
test(CLI): Update test template to use create_app_fixture (#2028)
1 parent a9f7807 commit 51da1cc

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
lines changed

shiny/_main_add_test.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -73,28 +73,10 @@ def path_does_not_exist(x: Path) -> bool | str:
7373
if not test_file.name.startswith("test_"):
7474
return "Test file must start with 'test_'"
7575

76-
# if app path directory is the same as the test file directory, use `local_app`
77-
# otherwise, use `create_app_fixture`
78-
is_same_dir = app_file.parent == test_file.parent
79-
8076
test_name = test_file.name.replace(".py", "")
8177
rel_path = os.path.relpath(app_file, test_file.parent)
8278

83-
template = (
84-
f"""\
85-
from playwright.sync_api import Page
86-
87-
from shiny.playwright import controller
88-
from shiny.run import ShinyAppProc
89-
90-
91-
def {test_name}(page: Page, local_app: ShinyAppProc):
92-
93-
page.goto(local_app.url)
94-
# Add test code here
95-
"""
96-
if is_same_dir
97-
else f"""\
79+
template = f"""\
9880
from playwright.sync_api import Page
9981
10082
from shiny.playwright import controller
@@ -109,7 +91,6 @@ def {test_name}(page: Page, app: ShinyAppProc):
10991
page.goto(app.url)
11092
# Add test code here
11193
"""
112-
)
11394
# Make sure test file directory exists
11495
test_file.parent.mkdir(parents=True, exist_ok=True)
11596

0 commit comments

Comments
 (0)