Skip to content

Commit a38aa0d

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 7bcf519 commit a38aa0d

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
@@ -131,7 +131,7 @@ jobs:
131131
- name: Test Reference count
132132
run: pytest tests/test_reference_count_async.py --browser=${{ matrix.browser }}
133133
- name: Test Wheel Installation
134-
run: pytest tests/test_installation.py --browser=${{ matrix.browser }}
134+
run: pytest tests/test_installation.py::test_install --browser=${{ matrix.browser }}
135135
- name: Test Sync API
136136
if: runner.os != 'Linux'
137137
run: pytest tests/sync --browser=${{ matrix.browser }} -n ${{ env.WORKERS }} -p pytest_dot_reporter -rfE --color=yes
@@ -227,12 +227,16 @@ jobs:
227227
pip install -e .
228228
- name: Get Playwright
229229
run: python scripts/upstream.py checkout
230-
- name: Build the driver and the sdist
230+
# The wheel build puts the driver with Node.js into the checkout, for the
231+
# install-deps step below. The test installs the sdist in its own venv.
232+
- name: Build the driver and the wheel
233+
run: python -m build --wheel
234+
- name: Build the sdist
231235
run: python -m build --sdist
232236
- name: Install browser dependencies
233-
run: PLAYWRIGHT_NODEJS_PATH=$(which node) python -m playwright install-deps chromium
237+
run: python -m playwright install-deps chromium
234238
- name: Test the sdist installation
235-
run: pytest tests/test_installation.py -k test_install_sdist --browser=chromium
239+
run: pytest tests/test_installation.py::test_install_sdist --browser=chromium
236240

237241
test_examples:
238242
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)