mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-12 16:56:02 +00:00
Merge remote-tracking branch 'origin/fix/utils-pkgmgr-extra-params-none' into validation/test-build-with-fixes
# Conflicts: # tests/unit_tests/utils/test_pkgmgr.py
This commit is contained in:
@@ -23,7 +23,10 @@ def run_pip(params: list):
|
|||||||
pipmain(params)
|
pipmain(params)
|
||||||
|
|
||||||
|
|
||||||
def install_requirements(file, extra_params: list = []):
|
def install_requirements(file, extra_params: list | None = None):
|
||||||
|
if extra_params is None:
|
||||||
|
extra_params = []
|
||||||
|
|
||||||
pipmain(
|
pipmain(
|
||||||
[
|
[
|
||||||
'install',
|
'install',
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ Tests pip command generation without actual installation.
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import inspect
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from langbot.pkg.utils import pkgmgr
|
from langbot.pkg.utils import pkgmgr
|
||||||
@@ -99,3 +100,34 @@ class TestPkgMgr:
|
|||||||
call_args = mock_pipmain.call_args[0][0]
|
call_args = mock_pipmain.call_args[0][0]
|
||||||
assert '--no-cache-dir' in call_args
|
assert '--no-cache-dir' in call_args
|
||||||
assert '--verbose' in call_args
|
assert '--verbose' in call_args
|
||||||
|
|
||||||
|
def test_install_requirements_defaults_extra_params_to_none(self):
|
||||||
|
"""install_requirements does not use a mutable list default."""
|
||||||
|
signature = inspect.signature(pkgmgr.install_requirements)
|
||||||
|
|
||||||
|
assert signature.parameters['extra_params'].default is None
|
||||||
|
|
||||||
|
def test_install_requirements_omitted_extra_params_are_isolated(self):
|
||||||
|
"""Repeated calls without extra_params use independent base commands."""
|
||||||
|
with patch('langbot.pkg.utils.pkgmgr.pipmain') as mock_pipmain:
|
||||||
|
pkgmgr.install_requirements('requirements.txt')
|
||||||
|
pkgmgr.install_requirements('requirements-dev.txt')
|
||||||
|
|
||||||
|
assert mock_pipmain.call_args_list[0].args[0] == [
|
||||||
|
'install',
|
||||||
|
'-r',
|
||||||
|
'requirements.txt',
|
||||||
|
'-i',
|
||||||
|
'https://pypi.tuna.tsinghua.edu.cn/simple',
|
||||||
|
'--trusted-host',
|
||||||
|
'pypi.tuna.tsinghua.edu.cn',
|
||||||
|
]
|
||||||
|
assert mock_pipmain.call_args_list[1].args[0] == [
|
||||||
|
'install',
|
||||||
|
'-r',
|
||||||
|
'requirements-dev.txt',
|
||||||
|
'-i',
|
||||||
|
'https://pypi.tuna.tsinghua.edu.cn/simple',
|
||||||
|
'--trusted-host',
|
||||||
|
'pypi.tuna.tsinghua.edu.cn',
|
||||||
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user