Skip to content

Commit cb34671

Browse files
committed
Merge branch 'main' into navset_docs_names
* main: Consolidate all testing into `tests/` folder (#683)
2 parents 30f7336 + 196f4cd commit cb34671

File tree

73 files changed

+18
-15
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+18
-15
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ check: ## check code quality with black and isort
7777
isort --check-only --diff .
7878

7979
test: ## run tests quickly with the default Python
80-
python3 tests/asyncio_prevent.py
81-
pytest tests
80+
python3 tests/pytest/asyncio_prevent.py
81+
pytest
8282

8383
# Default `FILE` to `e2e` if not specified
84-
FILE:=e2e
84+
FILE:=tests/e2e
8585

8686
e2e: ## end-to-end tests with playwright
8787
playwright install --with-deps

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[pytest]
22
asyncio_mode=strict
3-
testpaths=tests
3+
testpaths=tests/pytest/
44
addopts = --strict-markers --durations=6 --durations-min=5.0 --browser webkit --browser firefox --browser chromium --numprocesses auto
55
markers =
66
examples: Suite of tests to validate that examples do not produce errors (deselect with '-m "not examples"')

tests/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"""Unit test package for shiny."""
1+
"""Testing package for shiny. (Used by pytest)"""
File renamed without changes.
File renamed without changes.
File renamed without changes.

e2e/conftest.py renamed to tests/e2e/conftest.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
)
3030

3131
here = PurePath(__file__).parent
32+
here_root = here.parent.parent
3233

3334

3435
class OutputStream:
@@ -192,20 +193,20 @@ def fixture_func():
192193

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

197198

198199
def create_doc_example_fixture(example_name: str, scope: str = "module"):
199200
"""Used to create app fixtures from apps in py-shiny/shiny/api-examples"""
200201
return create_app_fixture(
201-
here / "../shiny/api-examples" / example_name / "app.py", scope
202+
here_root / "shiny/api-examples" / example_name / "app.py", scope
202203
)
203204

204205

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

211212

File renamed without changes.
File renamed without changes.

e2e/examples/test_examples.py renamed to tests/e2e/examples/test_examples.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
from conftest import run_shiny_app
77
from playwright.sync_api import ConsoleMessage, Page
88

9-
here = PurePath(__file__).parent
9+
here_tests_e2e_examples = PurePath(__file__).parent
10+
here_root = here_tests_e2e_examples.parent.parent.parent
1011

1112

1213
def get_apps(path: str) -> typing.List[str]:
13-
full_path = here / path
14+
full_path = here_root / path
1415
app_paths: typing.List[str] = []
1516
for folder in os.listdir(full_path):
1617
folder_path = os.path.join(full_path, folder)
@@ -23,8 +24,8 @@ def get_apps(path: str) -> typing.List[str]:
2324

2425

2526
example_apps: typing.List[str] = [
26-
*get_apps("../../examples"),
27-
*get_apps("../../shiny/api-examples"),
27+
*get_apps("examples"),
28+
*get_apps("shiny/api-examples"),
2829
]
2930

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

112113
console_errors: typing.List[str] = []
113114

File renamed without changes.

e2e/inputs/input_slider/app.py renamed to tests/e2e/inputs/input_slider/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

3-
from e2e.controls import typing
43
from shiny import App, Inputs, Outputs, Session, render, ui
4+
from tests.e2e.controls import typing
55

66
slider_nums: list[int] = []
77

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/pytest/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Pytest test module for shiny. (Used by pytest)"""
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/test_e2e_regex_matching.py renamed to tests/pytest/test_e2e_regex_matching.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import re
22

3-
from e2e.controls import _attr_match_str, _style_match_str, _xpath_match_str
3+
from tests.e2e.controls import _attr_match_str, _style_match_str, _xpath_match_str
44

55

66
def test_style_match_str() -> None:
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.

0 commit comments

Comments
 (0)