| 21 | |
| 22 | |
| 23 | def test_install(tmp_path: Path, browser_name: str) -> None: |
| 24 | env_dir = tmp_path / "env" |
| 25 | env = EnvBuilder(with_pip=True) |
| 26 | env.create(env_dir=env_dir) |
| 27 | context = env.ensure_directories(env_dir) |
| 28 | root = Path(__file__).parent.parent.resolve() |
| 29 | if sys.platform == "win32": |
| 30 | wheelpath = list((root / "dist").glob("playwright*win_amd64*.whl"))[0] |
| 31 | elif sys.platform == "linux": |
| 32 | wheelpath = list((root / "dist").glob("playwright*manylinux1*.whl"))[0] |
| 33 | elif sys.platform == "darwin": |
| 34 | wheelpath = list((root / "dist").glob("playwright*macosx_*.whl"))[0] |
| 35 | subprocess.check_output( |
| 36 | [ |
| 37 | context.env_exe, |
| 38 | "-m", |
| 39 | "pip", |
| 40 | "install", |
| 41 | str(wheelpath), |
| 42 | ] |
| 43 | ) |
| 44 | environ = os.environ.copy() |
| 45 | environ["PLAYWRIGHT_BROWSERS_PATH"] = str(tmp_path) |
| 46 | subprocess.check_output( |
| 47 | [context.env_exe, "-m", "playwright", "install", browser_name], env=environ |
| 48 | ) |
| 49 | shutil.copyfile(root / "tests" / "assets" / "client.py", tmp_path / "main.py") |
| 50 | subprocess.check_output( |
| 51 | [context.env_exe, str(tmp_path / "main.py"), browser_name], env=environ |
| 52 | ) |
| 53 | assert (tmp_path / f"{browser_name}.png").exists() |