Skip to content

Consolidate all testing into tests/ folder #683

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

Merged
merged 2 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ check: ## check code quality with black and isort
isort --check-only --diff .

test: ## run tests quickly with the default Python
python3 tests/asyncio_prevent.py
pytest tests
python3 tests/pytest/asyncio_prevent.py
pytest

# Default `FILE` to `e2e` if not specified
FILE:=e2e
FILE:=tests/e2e

e2e: ## end-to-end tests with playwright
playwright install --with-deps
Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[pytest]
asyncio_mode=strict
testpaths=tests
testpaths=tests/pytest/
addopts = --strict-markers --durations=6 --durations-min=5.0 --browser webkit --browser firefox --browser chromium --numprocesses auto
markers =
examples: Suite of tests to validate that examples do not produce errors (deselect with '-m "not examples"')
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"""Unit test package for shiny."""
"""Testing package for shiny. (Used by pytest)"""
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 4 additions & 3 deletions e2e/conftest.py → tests/e2e/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
)

here = PurePath(__file__).parent
here_root = here.parent.parent


class OutputStream:
Expand Down Expand Up @@ -192,20 +193,20 @@ def fixture_func():

def create_example_fixture(example_name: str, scope: str = "module"):
"""Used to create app fixtures from apps in py-shiny/examples"""
return create_app_fixture(here / "../examples" / example_name / "app.py", scope)
return create_app_fixture(here_root / "examples" / example_name / "app.py", scope)


def create_doc_example_fixture(example_name: str, scope: str = "module"):
"""Used to create app fixtures from apps in py-shiny/shiny/api-examples"""
return create_app_fixture(
here / "../shiny/api-examples" / example_name / "app.py", scope
here_root / "shiny/api-examples" / example_name / "app.py", scope
)


def x_create_doc_example_fixture(example_name: str, scope: str = "module"):
"""Used to create app fixtures from apps in py-shiny/shiny/examples"""
return create_app_fixture(
here / "../shiny/experimental/api-examples" / example_name / "app.py", scope
here_root / "shiny/experimental/api-examples" / example_name / "app.py", scope
)


Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
from conftest import run_shiny_app
from playwright.sync_api import ConsoleMessage, Page

here = PurePath(__file__).parent
here_tests_e2e_examples = PurePath(__file__).parent
here_root = here_tests_e2e_examples.parent.parent.parent


def get_apps(path: str) -> typing.List[str]:
full_path = here / path
full_path = here_root / path
app_paths: typing.List[str] = []
for folder in os.listdir(full_path):
folder_path = os.path.join(full_path, folder)
Expand All @@ -23,8 +24,8 @@ def get_apps(path: str) -> typing.List[str]:


example_apps: typing.List[str] = [
*get_apps("../../examples"),
*get_apps("../../shiny/api-examples"),
*get_apps("examples"),
*get_apps("shiny/api-examples"),
]

app_idle_wait = {"duration": 300, "timeout": 5 * 1000}
Expand Down Expand Up @@ -107,7 +108,7 @@ def wait_for_idle_app(
@pytest.mark.parametrize("ex_app_path", example_apps)
@pytest.mark.flaky(reruns=3, reruns_delay=1)
def test_examples(page: Page, ex_app_path: str) -> None:
app = run_shiny_app(here / ex_app_path, wait_for_start=True)
app = run_shiny_app(here_root / ex_app_path, wait_for_start=True)

console_errors: typing.List[str] = []

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from e2e.controls import typing
from shiny import App, Inputs, Outputs, Session, render, ui
from tests.e2e.controls import typing

slider_nums: list[int] = []

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions tests/pytest/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Pytest test module for shiny. (Used by pytest)"""
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import re

from e2e.controls import _attr_match_str, _style_match_str, _xpath_match_str
from tests.e2e.controls import _attr_match_str, _style_match_str, _xpath_match_str


def test_style_match_str() -> None:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.