Skip to content

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.
@schloerke
Copy link
Collaborator

Note: Advanced users can still use local_app test fixture.

@schloerke schloerke merged commit 51da1cc into main Jul 21, 2025
54 checks passed
@schloerke schloerke deleted the use-app-instead-of-local-app branch July 21, 2025 18:49
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.

3 participants