uv/crates/install-wheel-rs/test/test_install_wheel_rs.py
Charlie Marsh e824fe6d2b
Copy over install-wheel-rs crate (#33)
This PR copies over the `install-wheel-rs` crate at commit
`10730ea1a84c58af6b35fb74c89ed0578ab042b6` with no modifications.

It won't pass CI, but modifications will intentionally be confined to
later PRs.
2023-10-06 21:38:38 -04:00

35 lines
1 KiB
Python

import platform
from pathlib import Path
from subprocess import check_call, check_output
def check_installed(venv: Path) -> bool:
"""true: installed and working, false: not installed, borked: exception"""
try:
output = check_output(
[
venv.joinpath(
"Scripts" if platform.system() == "Windows" else "bin"
).joinpath("upsidedown")
],
input="hello world!",
text=True,
).strip()
except FileNotFoundError:
return False
assert output == "¡pꞁɹoʍ oꞁꞁǝɥ"
return True
def test_install_wheel_rs(pytestconfig, tmp_path):
from install_wheel_rs import LockedVenv
venv = tmp_path.joinpath("venv_test_install_wheel_rs")
check_call(["virtualenv", venv])
assert not check_installed(venv)
locked_venv = LockedVenv(venv)
wheel = pytestconfig.rootpath.joinpath(
"install-wheel-rs/test-data/upsidedown-0.4-py2.py3-none-any.whl"
)
locked_venv.install_wheel(wheel)
assert check_installed(venv)