-
-
Notifications
You must be signed in to change notification settings - Fork 540
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'integration-test-framework' into testing-docs
- Loading branch information
Showing
18 changed files
with
64 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from nicegui import Client, ui | ||
|
||
# pylint: disable=missing-function-docstring | ||
|
||
|
||
def startup() -> None: | ||
@ui.page('/') | ||
def main_page() -> None: | ||
ui.markdown('Try running `pytest` on this project!') | ||
ui.button('Click me', on_click=lambda: ui.notify('Button clicked!')) | ||
ui.link('go to subpage', '/subpage') | ||
|
||
@ui.page('/subpage') | ||
def sub_page() -> None: | ||
ui.markdown('This is a subpage') | ||
|
||
@ui.page('/with_connected') | ||
async def with_connected(client: Client) -> None: | ||
ui.markdown('This is an async connection demo') | ||
await client.connected() | ||
ui.markdown('Connected!') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,8 @@ | ||
#!/usr/bin/env python3 | ||
from nicegui import Client, ui | ||
from app.startup import startup | ||
|
||
# pylint: disable=missing-function-docstring | ||
from nicegui import app, ui | ||
|
||
app.on_startup(startup) | ||
|
||
@ui.page('/') | ||
def main_page() -> None: | ||
ui.markdown('Try running `pytest` on this project!') | ||
ui.button('Click me', on_click=lambda: ui.notify('Button clicked!')) | ||
ui.link('go to subpage', '/subpage') | ||
|
||
|
||
@ui.page('/subpage') | ||
def sub_page() -> None: | ||
ui.markdown('This is a subpage') | ||
|
||
|
||
@ui.page('/with_connected') | ||
async def with_connected(client: Client) -> None: | ||
ui.markdown('This is an async connection demo') | ||
await client.connected() | ||
ui.markdown('Connected!') | ||
|
||
|
||
if __name__ in {'__main__', '__mp_main__'}: | ||
ui.run() | ||
ui.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[pytest] | ||
asyncio_mode = auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
nicegui | ||
icecream | ||
pytest-asyncio | ||
pytest-selenium |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from typing import Generator | ||
|
||
import pytest | ||
from app.startup import startup | ||
|
||
from nicegui.testing import Screen, User | ||
|
||
pytest_plugins = ['nicegui.testing.plugin'] | ||
|
||
|
||
@pytest.fixture | ||
def user(user: User) -> Generator[User, None, None]: | ||
startup() | ||
yield user | ||
|
||
|
||
@pytest.fixture | ||
def screen(screen: Screen) -> Generator[Screen, None, None]: | ||
startup() | ||
yield screen |
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
examples/pytests/tests/test_with_routing.py → examples/pytests/tests/test_with_screen.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,31 @@ | ||
import importlib | ||
|
||
from nicegui.testing import Screen | ||
|
||
from .. import main | ||
|
||
# pylint: disable=missing-function-docstring | ||
|
||
|
||
def test_markdown_message(screen: Screen) -> None: | ||
importlib.reload(main) | ||
|
||
screen.open('/') | ||
screen.should_contain('Try running') | ||
|
||
|
||
def test_button_click(screen: Screen) -> None: | ||
importlib.reload(main) | ||
|
||
screen.open('/') | ||
screen.click('Click me') | ||
screen.should_contain('Button clicked!') | ||
|
||
|
||
def test_sub_page(screen: Screen) -> None: | ||
importlib.reload(main) | ||
|
||
screen.open('/subpage') | ||
screen.should_contain('This is a subpage') | ||
|
||
|
||
def test_with_connected(screen: Screen) -> None: | ||
importlib.reload(main) | ||
|
||
screen.open('/with_connected') | ||
screen.should_contain('This is an async connection demo') | ||
screen.should_contain('Connected!') | ||
|
||
|
||
def test_navigation(screen: Screen) -> None: | ||
importlib.reload(main) | ||
|
||
screen.open('/') | ||
screen.click('go to subpage') | ||
screen.should_contain('This is a subpage') |
9 changes: 0 additions & 9 deletions
9
...ytests/tests/test_with_user_simulation.py → examples/pytests/tests/test_with_user.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
# pylint: disable=wildcard-import,unused-wildcard-import | ||
from nicegui.testing.fixtures import * # noqa: F403 | ||
pytest_plugins = ['nicegui.testing.plugin'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters