diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 3520483..1be8bb8 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -30,7 +30,7 @@ jobs: - name: Ensure browsers are installed run: python -m playwright install --with-deps - name: Run your tests - run: pytest -v + run: pytest -v --browser=firefox --browser=webkit --browser=chromium - uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} with: diff --git a/Dockerfile.pytests b/Dockerfile.pytests new file mode 100644 index 0000000..b16e879 --- /dev/null +++ b/Dockerfile.pytests @@ -0,0 +1,7 @@ +FROM python:3.12-slim +WORKDIR /app +COPY poetry.lock pyproject.toml . +RUN pip install poetry && poetry config virtualenvs.create false && poetry install +COPY . . +CMD ["poetry", "run", "pytest"] + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..41228af --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +build: + docker build -f Dockerfile.pytests -t puepy-pytest . + +test: build + docker run -it --rm puepy-pytest diff --git a/poetry.lock b/poetry.lock index 699a1b3..0886273 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. [[package]] name = "certifi" @@ -439,4 +439,4 @@ zstd = ["zstandard (>=0.18.0)"] [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "6b7a947c45c168331f8dd96bccb393f2b927846f47f073da6f01b0eba64d1eba" +content-hash = "db383663b39f054fcfa07a6e3823543a133c60f2a5034f4fe9d64f00d30fc062" diff --git a/pyproject.toml b/pyproject.toml index 9ad28b8..7110cc2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,8 +25,8 @@ python = "^3.9" [tool.poetry.group.dev.dependencies] -pytest-playwright = "^0.5.0" -pytest = "^8.2.2" +pytest-playwright = "^0.5.1" +pytest = "^8.3.2" [build-system] requires = ["poetry-core"] diff --git a/tests/integration/test_examples.py b/tests/integration/test_examples.py index 8b77388..f2c897f 100644 --- a/tests/integration/test_examples.py +++ b/tests/integration/test_examples.py @@ -56,7 +56,7 @@ def test_hello_world(http_server, page: Page): expect(page.locator("h1")).to_contain_text("Hello, World!") -def test_hello_name(page: Page): +def test_hello_name(http_server, page: Page): page.goto(f"http://localhost:{PORT}/") page.get_by_role("link", name="Example 2: Hello, Name").click() page.get_by_placeholder("name").click() @@ -65,7 +65,7 @@ def test_hello_name(page: Page): expect(page.locator("h1")).to_contain_text("Hello, Jack!") -def test_counter(page: Page): +def test_counter(http_server, page: Page): page.goto(f"http://localhost:{PORT}/") page.get_by_role("link", name="Example 3: Counter").click() page.get_by_role("button", name="+").click() @@ -80,7 +80,7 @@ def test_counter(page: Page): expect(page.locator(".count")).to_contain_text("-1") -def test_refs_problem(page: Page): +def test_refs_problem(http_server, page: Page): def input_is_active(): return page.evaluate("document.querySelector(\"[placeholder='Type a word']\") === document.activeElement") @@ -98,7 +98,7 @@ def input_is_active(): assert not input_is_active() -def test_refs_solution(page: Page): +def test_refs_solution(http_server, page: Page): def input_is_active(): return page.evaluate("document.querySelector(\"[placeholder='Type a word']\") === document.activeElement") @@ -111,7 +111,7 @@ def input_is_active(): assert input_is_active() -def test_watchers(page: Page): +def test_watchers(http_server, page: Page): page.goto(f"http://localhost:{PORT}/") page.get_by_role("link", name="Example 5: Watchers").click() page.get_by_placeholder("Enter a guess").click() @@ -122,7 +122,7 @@ def test_watchers(page: Page): page.get_by_text("You guessed the number!").click() -def test_components(page: Page): +def test_components(http_server, page: Page): page.goto(f"http://localhost:{PORT}/") page.get_by_role("link", name="Example 6: Components").click() @@ -134,7 +134,7 @@ def test_components(page: Page): expect(page.locator("#result")).to_contain_text("Custom event from card with type error") -def test_routing(page: Page): +def test_routing(http_server, page: Page): page.goto(f"http://localhost:{PORT}/") page.get_by_role("link", name="Example 7: Routing").click() @@ -151,7 +151,7 @@ def test_routing(page: Page): page.get_by_role("heading", name="PuePy Routing Demo: Pet").click() -def test_pypi_libraries(page: Page): +def test_pypi_libraries(http_server, page: Page): page.goto(f"http://localhost:{PORT}/") page.get_by_role("link", name="Example 8: PyPi Libraries").click() page.get_by_role("textbox").first.click() @@ -169,14 +169,14 @@ def test_pypi_libraries(page: Page): ) -def test_webcomponents(page: Page): +def test_webcomponents(http_server, page: Page): page.goto(f"http://localhost:{PORT}/") page.get_by_role("link", name="Example 9: WebComponents").click() page.get_by_role("button", name="Open Dialog").click() page.locator("sl-button").filter(has_text="Close").get_by_role("button").click() -def test_a_full_app(page: Page): +def test_a_full_app(http_server, page: Page): page.goto(f"http://localhost:{PORT}/") page.get_by_role("link", name="Example 10: A full-blown app").click()