uv run --with installs a dependency on-the-fly and runs a script using it.
(
sandbox: Callable[..., Sandbox],
)
| 102 | |
| 103 | |
| 104 | def test_uv_run_with_ephemeral_dependency( |
| 105 | sandbox: Callable[..., Sandbox], |
| 106 | ) -> None: |
| 107 | """uv run --with installs a dependency on-the-fly and runs a script using it.""" |
| 108 | with sandbox(delete_on_exit=True) as sb: |
| 109 | result = sb.exec( |
| 110 | [ |
| 111 | "uv", |
| 112 | "run", |
| 113 | "--python", |
| 114 | "/sandbox/.venv/bin/python", |
| 115 | "--with", |
| 116 | "cowsay", |
| 117 | "python", |
| 118 | "-c", |
| 119 | "import cowsay; print(cowsay.char_names[0])", |
| 120 | ], |
| 121 | timeout_seconds=60, |
| 122 | ) |
| 123 | assert result.exit_code == 0, ( |
| 124 | f"uv run --with failed:\nstdout: {result.stdout}\nstderr: {result.stderr}" |
| 125 | ) |
| 126 | assert result.stdout.strip(), "Expected non-empty output from uv run" |