Skip to content

Commit

Permalink
Merge branch 'sync-use-opts-from-txt' into pip-tools-integration
Browse files Browse the repository at this point in the history
* sync-use-opts-from-txt:
  tests: Add test for sync using options from txt file
  sync: Use options from the txt file
  • Loading branch information
suutari committed Jan 7, 2018
2 parents 4434bdc + a2a94c9 commit e2688fa
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,39 @@ def test_sync_quiet(tmpdir):
assert '-q' in call[0][0]


@pytest.mark.parametrize('option_name', [
'find-links', 'f', 'no-index', 'index-url', 'i', 'extra-index-url'])
def test_sync_uses_opts_from_txt_file(option_name):
"""sync command uses pip options from the txt file."""
(opt_in_txt_file, pip_opt) = {
'find-links': ('--find-links ./pkg-dir', '-f ./pkg-dir'),
'f': ('-f ./pkg-dir', '-f ./pkg-dir'),
'no-index': ('--no-index', '--no-index'),
'index-url': ('--index-url http://index-url', '-i http://index-url'),
'i': ('-i http://index.localhost', '-i http://index.localhost'),
'extra-index-url': (
'--extra-index-url http://extra-index.localhost',
'--extra-index-url http://extra-index.localhost'),
}[option_name]
runner = CliRunner()
with runner.isolated_filesystem():
with open('requirements.txt', 'w') as req_txt:
req_txt.write('{}\n'.format(opt_in_txt_file))
req_txt.write('foobar==0.42\n')

with mock.patch('piptools.sync.check_call') as check_call:
run_result = runner.invoke(sync_cli, ['-q'])
assert run_result.output == ''
assert run_result.exit_code == 0
number_of_install_calls = 0
for (call_args, _call_kwargs) in check_call.call_args_list:
cmd = ' '.join(call_args[0])
if cmd.startswith('pip install'):
assert pip_opt in cmd
number_of_install_calls += 1
assert number_of_install_calls == 1


def test_editable_package(small_fake_package_dir):
""" piptools can compile an editable """
small_fake_package_dir = 'file:' + pathname2url(small_fake_package_dir)
Expand Down

0 comments on commit e2688fa

Please sign in to comment.