mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-02 03:55:55 +00:00
fix pkgmgr install requirements default (#2190)
This commit is contained in:
@@ -23,7 +23,10 @@ def run_pip(params: list):
|
||||
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(
|
||||
[
|
||||
'install',
|
||||
|
||||
1
tests/unit_tests/utils/__init__.py
Normal file
1
tests/unit_tests/utils/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
58
tests/unit_tests/utils/test_pkgmgr.py
Normal file
58
tests/unit_tests/utils/test_pkgmgr.py
Normal file
@@ -0,0 +1,58 @@
|
||||
import inspect
|
||||
|
||||
from langbot.pkg.utils import pkgmgr
|
||||
|
||||
|
||||
def test_install_requirements_defaults_extra_params_to_none():
|
||||
signature = inspect.signature(pkgmgr.install_requirements)
|
||||
|
||||
assert signature.parameters['extra_params'].default is None
|
||||
|
||||
|
||||
def test_install_requirements_omitted_extra_params_uses_base_command(monkeypatch):
|
||||
calls = []
|
||||
monkeypatch.setattr(pkgmgr, 'pipmain', calls.append)
|
||||
|
||||
pkgmgr.install_requirements('requirements.txt')
|
||||
pkgmgr.install_requirements('requirements-dev.txt')
|
||||
|
||||
assert calls == [
|
||||
[
|
||||
'install',
|
||||
'-r',
|
||||
'requirements.txt',
|
||||
'-i',
|
||||
'https://pypi.tuna.tsinghua.edu.cn/simple',
|
||||
'--trusted-host',
|
||||
'pypi.tuna.tsinghua.edu.cn',
|
||||
],
|
||||
[
|
||||
'install',
|
||||
'-r',
|
||||
'requirements-dev.txt',
|
||||
'-i',
|
||||
'https://pypi.tuna.tsinghua.edu.cn/simple',
|
||||
'--trusted-host',
|
||||
'pypi.tuna.tsinghua.edu.cn',
|
||||
],
|
||||
]
|
||||
|
||||
|
||||
def test_install_requirements_preserves_explicit_extra_params(monkeypatch):
|
||||
calls = []
|
||||
monkeypatch.setattr(pkgmgr, 'pipmain', calls.append)
|
||||
|
||||
pkgmgr.install_requirements('requirements.txt', extra_params=['--no-deps'])
|
||||
|
||||
assert calls == [
|
||||
[
|
||||
'install',
|
||||
'-r',
|
||||
'requirements.txt',
|
||||
'-i',
|
||||
'https://pypi.tuna.tsinghua.edu.cn/simple',
|
||||
'--trusted-host',
|
||||
'pypi.tuna.tsinghua.edu.cn',
|
||||
'--no-deps',
|
||||
]
|
||||
]
|
||||
Reference in New Issue
Block a user