Skip to content

Commit a265102

Browse files
authored
test: don't restart browser for every sync test (microsoft#268)
1 parent 7bace3d commit a265102

File tree

3 files changed

+17
-19
lines changed

3 files changed

+17
-19
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,19 @@ jobs:
6060
run: python build_package.py
6161
- name: Install
6262
run: python -m playwright install
63-
- name: Test
63+
- name: Test Sync API
6464
if: matrix.os != 'ubuntu-latest'
65-
run: pytest -vv --browser=${{ matrix.browser }} --junitxml=junit/test-results-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.browser }}.xml --timeout 90
66-
- name: Test
65+
run: pytest -vv tests/sync --browser=${{ matrix.browser }} --timeout 90
66+
- name: Test Sync API
6767
if: matrix.os == 'ubuntu-latest'
68-
run: xvfb-run pytest -vv --browser=${{ matrix.browser }} --junitxml=junit/test-results-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.browser }}.xml --timeout 90
69-
- name: Upload pytest test results
70-
uses: actions/upload-artifact@v1
71-
with:
72-
name: pytest-results-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.browser }}.xml
73-
path: junit/test-results-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.browser }}.xml
74-
# Use always() to always run this step to publish test results when there are test failures
75-
if: ${{ always() }}
68+
run: xvfb-run pytest -vv tests/sync --browser=${{ matrix.browser }} --timeout 90
69+
- name: Test Async API
70+
if: matrix.os != 'ubuntu-latest'
71+
run: pytest -vv tests/async --browser=${{ matrix.browser }} --timeout 90
72+
- name: Test Async API
73+
if: matrix.os == 'ubuntu-latest'
74+
run: xvfb-run pytest -vv tests/async --browser=${{ matrix.browser }} --timeout 90
75+
7676
test-package-installations:
7777
name: Test package installations
7878
runs-on: ubuntu-latest

tests/sync/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
from playwright import sync_playwright
1919

2020

21-
@pytest.fixture
21+
@pytest.fixture(scope="session")
2222
def playwright():
2323
with sync_playwright() as p:
2424
yield p
2525

2626

27-
@pytest.fixture
27+
@pytest.fixture(scope="session")
2828
def browser(playwright, browser_name, launch_arguments):
2929
browser_type = None
3030
if browser_name == "chromium":

tests/sync/test_sync.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,10 @@ def test_sync_workers_page_workers(page: Page, server):
174174

175175

176176
def test_sync_playwright_multiple_times():
177-
with sync_playwright() as pw1:
178-
assert pw1.chromium
179-
with pytest.raises(Error) as exc:
180-
with sync_playwright() as pw2:
181-
assert pw1.chromium == pw2.chromium
182-
assert "Can only run one Playwright at a time." in exc.value.message
177+
with pytest.raises(Error) as exc:
178+
with sync_playwright() as pw:
179+
assert pw.chromium
180+
assert "Can only run one Playwright at a time." in exc.value.message
183181

184182

185183
def test_sync_set_default_timeout(page):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy