Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions template/pyproject.toml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ commands = [
[
"{{ type_checker }}",
{% if type_checker=="pyright" %}"--pythonpath",
".venv/bin/python",
"{env:VIRTUAL_ENV}/bin/python",
{% endif %}"src",
"tests",
{ replace = "posargs", default = [
Expand All @@ -116,7 +116,7 @@ commands = [
description = "Run tests with coverage"
commands = [
[
"pytest",
"pytest",
"--cov={{ package_name }}",
"--cov-report",
"term",
Expand Down
6 changes: 4 additions & 2 deletions tests/test_example.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import functools
import json
import os
import shlex
import subprocess
import tomllib
Expand Down Expand Up @@ -27,12 +28,13 @@ def copy_project(project_path: Path, **kwargs):
run_pipe("git add .", cwd=str(project_path))


def run_pipe(cmd: str, cwd=None) -> str:
def run_pipe(cmd: str, cwd=None, venv="") -> str:
sp = subprocess.run(
shlex.split(cmd),
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
cwd=cwd,
env=dict(os.environ, UV_PROJECT_ENVIRONMENT="", VIRTUAL_ENV=venv),
)
output = sp.stdout.decode()
assert sp.returncode == 0, output
Expand All @@ -41,7 +43,7 @@ def run_pipe(cmd: str, cwd=None) -> str:

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

for exe_path in [
Expand Down
Loading