aboutsummaryrefslogtreecommitdiff
path: root/app/tests/test_backends.py
diff options
context:
space:
mode:
authorhistoria <historiavg@proton.me>2026-08-27 00:04:16 -0400
committerhistoria <historiavg@proton.me>2026-08-27 00:04:16 -0400
commit5b98993b13dafe9a85495e4c68ad9b42863ef2bf (patch)
tree57db1566deb5351ec6bfb8c70de4126bbc5fc2da /app/tests/test_backends.py
parentf18f421d9180ae0e3bff9496b1fdaf53d3624a75 (diff)
downloadtts-audiobook-generator-5b98993b13dafe9a85495e4c68ad9b42863ef2bf.tar.gz
feat: separate venvs for qwen-tts and faster, manage (un)installs
Diffstat (limited to 'app/tests/test_backends.py')
-rw-r--r--app/tests/test_backends.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/app/tests/test_backends.py b/app/tests/test_backends.py
index 1e1a3f9..7fdcce6 100644
--- a/app/tests/test_backends.py
+++ b/app/tests/test_backends.py
@@ -420,7 +420,8 @@ class QwenUninstallWeightsTests(unittest.TestCase):
return_value=0) as mk_pip:
rc = qwen.uninstall(emit="EMIT")
self.assertEqual(rc, 0)
- mk_pip.assert_called_once_with([qwen.QWEN_PIP_PKG], emit="EMIT")
+ mk_pip.assert_called_once_with([qwen.QWEN_PIP_PKG], emit="EMIT",
+ env_dir=qwen.QWEN_ENV)
self.assertEqual(list(Path(td).iterdir()), [])
def test_weights_deleted_even_when_pip_failed(self):
@@ -459,7 +460,8 @@ class QwenUninstallWeightsTests(unittest.TestCase):
side_effect=pip_flips_cancel) as mk_pip:
rc = qwen.uninstall(cancel=cancel)
self.assertEqual(rc, 130)
- mk_pip.assert_called_once_with([qwen.QWEN_PIP_PKG], emit=None)
+ mk_pip.assert_called_once_with([qwen.QWEN_PIP_PKG], emit=None,
+ env_dir=qwen.QWEN_ENV)
# Cancelled between phases: the weights stay untouched...
self.assertEqual(len(list(Path(td).iterdir())), 3)
@@ -549,13 +551,14 @@ class QwenInstallModelTests(unittest.TestCase):
def test_hf_cli_prefers_hf_then_falls_back(self):
from backends import qwen
with tempfile.TemporaryDirectory() as td:
- with patch.object(qwen.envs, "ENV_DIR", Path(td)):
+ # The CLI is looked up in the qwen backend's own venv.
+ with patch.object(qwen, "QWEN_ENV", Path(td)):
self.assertIsNone(qwen._hf_download_prefix())
- cli = qwen.envs.env_script("huggingface-cli")
+ cli = qwen.envs.env_script("huggingface-cli", qwen.QWEN_ENV)
cli.parent.mkdir(parents=True)
cli.write_bytes(b"x")
self.assertEqual(qwen._hf_download_prefix(), [str(cli)])
- hf = qwen.envs.env_script("hf")
+ hf = qwen.envs.env_script("hf", qwen.QWEN_ENV)
hf.write_bytes(b"x")
self.assertEqual(qwen._hf_download_prefix(), [str(hf)])
@@ -827,8 +830,10 @@ class QwenUninstallTests(unittest.TestCase):
self.assertEqual(rc, 0)
self.assertEqual([c.args[0] for c in mk_stop.call_args_list],
["qwen"])
- # The task view's emit is forwarded so pip never touches the terminal.
- mk_pip.assert_called_once_with([qwen.QWEN_PIP_PKG], emit="EMIT")
+ # The task view's emit is forwarded so pip never touches the terminal,
+ # and the package comes out of the qwen backend's own venv.
+ mk_pip.assert_called_once_with([qwen.QWEN_PIP_PKG], emit="EMIT",
+ env_dir=qwen.QWEN_ENV)
def test_skips_stop_when_no_server_was_started(self):
# No pid files: stop() is not called (no "not started by this