Skip to content

Commit 5cadc93

Browse files
committed
Remove duplicate app fixture and test template code
Eliminated redundant app fixture and test function template from shiny/_main_add_test.py, streamlining the code and preventing duplication.
1 parent 53cf486 commit 5cadc93

File tree

1 file changed

+1
-19
lines changed

1 file changed

+1
-19
lines changed

shiny/_main_add_test.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -80,24 +80,7 @@ def path_does_not_exist(x: Path) -> bool | str:
8080
test_name = test_file.name.replace(".py", "")
8181
rel_path = os.path.relpath(app_file, test_file.parent)
8282

83-
template = (
84-
f"""\
85-
from playwright.sync_api import Page
86-
87-
from shiny.playwright import controller
88-
from shiny.pytest import create_app_fixture
89-
from shiny.run import ShinyAppProc
90-
91-
app = create_app_fixture("{app_file.name}")
92-
93-
94-
def {test_name}(page: Page, app: ShinyAppProc):
95-
96-
page.goto(app.url)
97-
# Add test code here
98-
"""
99-
if is_same_dir
100-
else f"""\
83+
template = f"""\
10184
from playwright.sync_api import Page
10285
10386
from shiny.playwright import controller
@@ -112,7 +95,6 @@ def {test_name}(page: Page, app: ShinyAppProc):
11295
page.goto(app.url)
11396
# Add test code here
11497
"""
115-
)
11698
# Make sure test file directory exists
11799
test_file.parent.mkdir(parents=True, exist_ok=True)
118100

0 commit comments

Comments
 (0)