Skip to content

Commit

Permalink
improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
jchopard committed Oct 29, 2019
1 parent 72f7312 commit 2435c54
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
18 changes: 17 additions & 1 deletion test/test_option/test_reqs/test_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from pkglts.config_management import Config
from pkglts.dependency import Dependency
from pkglts.option.reqs.option import OptionReqs, fmt_conda_reqs, fmt_pip_reqs
from pkglts.option.reqs.option import OptionReqs, fmt_conda_reqs, fmt_pip_reqs, requirements


@pytest.fixture()
Expand Down Expand Up @@ -34,6 +34,14 @@ def test_require(opt):
assert len(tuple(opt.require(cfg))) == 0


def test_require_puts_list_of_reqs_in_requirements(opt):
cfg = Config()
opt.update_parameters(cfg)
cfg['reqs']['require'].append({'pkg_mng': 'walou', 'name': 'numpy'})

assert 'numpy' in (dep.name for dep in requirements(cfg))


def test_fmt_conda_reqs_works_correctly():
assert fmt_conda_reqs([], ['install']) == ""

Expand All @@ -50,6 +58,10 @@ def test_fmt_conda_reqs_works_correctly():

assert fmt_conda_reqs([d], ['install']) == "conda install -c extra d"

d = Dependency('d', version='= 5')

assert fmt_conda_reqs([d], ['install']) == 'conda install "d= 5"'


def test_fmt_pip_reqs_works_correctly():
assert fmt_pip_reqs([], ['install']) == ""
Expand All @@ -62,3 +74,7 @@ def test_fmt_pip_reqs_works_correctly():
cmd = fmt_pip_reqs([d1, dex, dconda, dpip], ['install'])

assert cmd.strip() == "pip install dpip"

d = Dependency('d', pkg_mng='pip', version='= 5')

assert fmt_pip_reqs([d], ['install']) == 'pip install "d== 5"'
3 changes: 3 additions & 0 deletions test/test_option/test_reqs/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ def test_requirements():
cfg.load_extra()
assert len(cfg._env.globals['reqs'].requirements('install')) == 0
assert len(cfg._env.globals['reqs'].requirements('test')) == 2
assert len(cfg._env.globals['reqs'].intents()) >= 4
assert len(cfg._env.globals['reqs'].conda_reqs('install')) >= 0
assert len(cfg._env.globals['reqs'].pip_reqs('install')) >= 0

0 comments on commit 2435c54

Please sign in to comment.