Skip to content

Commit ab5bcf4

Browse files
dgozmanclaude
andcommitted
test(build): fix the installation tests of the sdist
- The wheel jobs run test_install only; the sdist job runs test_install_sdist. Each job builds the one artifact its test installs. - The sdist job builds the wheel first, so that the checkout has a driver with Node.js for install-deps. - The client subprocesses of the tests run from tmp_path, so that they import the installed package and not the checkout. - The sdist test installs with --no-binary :all:, the pip form of poetry's installer.no-binary policy of the report. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 1526b34 commit ab5bcf4

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ jobs:
135135
- name: Test Reference count
136136
run: $CI_ENV_EXEC pytest tests/test_reference_count_async.py --browser=${{ matrix.browser }}
137137
- name: Test Wheel Installation
138-
run: $CI_ENV_EXEC pytest tests/test_installation.py --browser=${{ matrix.browser }}
138+
run: $CI_ENV_EXEC pytest tests/test_installation.py::test_install --browser=${{ matrix.browser }}
139139
- name: Test Sync API
140140
run: $CI_ENV_EXEC pytest tests/sync --browser=${{ matrix.browser }} -n ${{ env.WORKERS }} -p pytest_dot_reporter -rfE --color=yes
141141
- name: Test Async API
@@ -221,12 +221,16 @@ jobs:
221221
pip install -e .
222222
- name: Get Playwright
223223
run: python scripts/upstream.py checkout
224-
- name: Build the driver and the sdist
224+
# The wheel build puts the driver with Node.js into the checkout, for the
225+
# install-deps step below. The test installs the sdist in its own venv.
226+
- name: Build the driver and the wheel
227+
run: python -m build --wheel
228+
- name: Build the sdist
225229
run: python -m build --sdist
226230
- name: Install browser dependencies
227-
run: PLAYWRIGHT_NODEJS_PATH=$(which node) python -m playwright install-deps chromium
231+
run: python -m playwright install-deps chromium
228232
- name: Test the sdist installation
229-
run: pytest tests/test_installation.py -k test_install_sdist --browser=chromium
233+
run: pytest tests/test_installation.py::test_install_sdist --browser=chromium
230234

231235
test_examples:
232236
name: Examples

‎tests/test_installation.py‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,16 @@ def _create_venv(env_dir: Path) -> str:
3131

3232

3333
def _run_client(python: str, tmp_path: Path, browser_name: str, environ: dict) -> None:
34+
# cwd=tmp_path: from the repository root, "-m playwright" imports the checkout
35+
# instead of the installed package.
3436
subprocess.check_output(
35-
[python, "-m", "playwright", "install", browser_name], env=environ
37+
[python, "-m", "playwright", "install", browser_name],
38+
cwd=tmp_path,
39+
env=environ,
3640
)
3741
shutil.copyfile(ROOT / "tests" / "assets" / "client.py", tmp_path / "main.py")
3842
subprocess.check_output(
39-
[python, str(tmp_path / "main.py"), browser_name], env=environ
43+
[python, str(tmp_path / "main.py"), browser_name], cwd=tmp_path, env=environ
4044
)
4145
assert (tmp_path / f"{browser_name}.png").exists()
4246

@@ -66,7 +70,12 @@ def test_install_sdist(tmp_path: Path, browser_name: str) -> None:
6670
assert node, "node must be in PATH"
6771
python = _create_venv(tmp_path / "env")
6872
sdist = list((ROOT / "dist").glob("playwright-*.tar.gz"))[0]
69-
subprocess.check_output([python, "-m", "pip", "install", str(sdist)])
73+
# No wheels at all, as poetry's installer.no-binary=:all: in the report: the
74+
# dependencies come from source too. The isolated build environment still
75+
# takes wheels: pip does not pass the policy on to it, and neither does poetry.
76+
subprocess.check_output(
77+
[python, "-m", "pip", "install", "--no-binary", ":all:", str(sdist)]
78+
)
7079
driver_dir = Path(
7180
subprocess.check_output(
7281
[

0 commit comments

Comments
 (0)