Skip to content

test(CLI): Update test template to use create_app_fixture #2028

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

karangattu
Copy link
Collaborator

Replaces the use of local_app with app for ShinyAppProc. This improves consistency and aligns with updated testing practices.

So now when the user runs shiny add test and the app dir is accordion/app_express.py
if the user chooses the tests to be created as accordion/tests/test_app.py
the created file will look like this

from playwright.sync_api import Page

from shiny.playwright import controller
from shiny.pytest import create_app_fixture
from shiny.run import ShinyAppProc

app = create_app_fixture("../app-express.py")


def test_accordion_demo1(page: Page, app: ShinyAppProc) -> None:
    page.goto(app.url)

Else if the user chooses the tests to be created as accordion/test_app.py i.e. living besides the app_express.py file, the created file will look like this

from playwright.sync_api import Page

from shiny.playwright import controller
from shiny.pytest import create_app_fixture
from shiny.run import ShinyAppProc

app = create_app_fixture("app-express.py")


def test_accordion_demo1(page: Page, app: ShinyAppProc) -> None:

Replaces the use of 'local_app' with 'app' and utilizes 'create_app_fixture' from shiny.pytest for test setup. This improves consistency and aligns with updated testing practices.
Eliminated redundant app fixture and test function template from shiny/_main_add_test.py, streamlining the code and preventing duplication.
@karangattu karangattu requested a review from schloerke July 13, 2025 08:18
Deleted the is_same_dir variable and related comments from add_test_file as it was not used in the function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant