Skip to content

Commit 331c0ab

Browse files
committed
fix: Use .venv in tmp directory for create tests
UV_PROJECT_ENVIRONMENT="" makes uv create .venv in project director VIRTUAL_VENV= is required so that pyright can find external dependencies for its checks
1 parent 0181497 commit 331c0ab

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tests/test_example.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import functools
22
import json
3+
import os
34
import shlex
45
import subprocess
56
import tomllib
@@ -27,12 +28,13 @@ def copy_project(project_path: Path, **kwargs):
2728
run_pipe("git add .", cwd=str(project_path))
2829

2930

30-
def run_pipe(cmd: str, cwd=None) -> str:
31+
def run_pipe(cmd: str, cwd=None, venv="") -> str:
3132
sp = subprocess.run(
3233
shlex.split(cmd),
3334
stdout=subprocess.PIPE,
3435
stderr=subprocess.STDOUT,
3536
cwd=cwd,
37+
env=dict(os.environ, UV_PROJECT_ENVIRONMENT="", VIRTUAL_ENV=venv),
3638
)
3739
output = sp.stdout.decode()
3840
assert sp.returncode == 0, output
@@ -41,7 +43,7 @@ def run_pipe(cmd: str, cwd=None) -> str:
4143

4244
def make_venv(project_path: Path) -> Callable[[str], str]:
4345
venv_path = project_path / ".venv"
44-
run = functools.partial(run_pipe, cwd=str(project_path))
46+
run = functools.partial(run_pipe, cwd=str(project_path), venv=venv_path)
4547
run("uv sync") # Create a lockfile and install packages
4648

4749
for exe_path in [

0 commit comments

Comments
 (0)