Skip to content

Commit

Permalink
Merge pull request #765 from atugushev/pip-sync-quiet-no-output
Browse files Browse the repository at this point in the history
Show less output on sync with quiet option
  • Loading branch information
atugushev authored Mar 19, 2019
2 parents 8de11ae + 118c6ec commit bc28e36
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
4 changes: 3 additions & 1 deletion piptools/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ def sync(to_install, to_uninstall, verbose=False, dry_run=False, install_flags=N
Install and uninstalls the given sets of modules.
"""
if not to_uninstall and not to_install:
click.echo("Everything up-to-date")
if verbose:
click.echo("Everything up-to-date")
return 0

pip_flags = []
if not verbose:
Expand Down
16 changes: 16 additions & 0 deletions tests/test_cli_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@ def test_quiet_option(tmpdir):
assert '-q' in call[0][0]


@mock.patch('piptools.sync.check_call')
def test_quiet_option_when_up_to_date(check_call, runner):
"""
Sync should output nothing when everything is up to date and quiet option is set.
"""
with open('requirements.txt', 'w'):
pass

with mock.patch('piptools.sync.diff', return_value=(set(), set())):
out = runner.invoke(cli, ['-q'])

assert out.output == ''
assert out.exit_code == 0
check_call.assert_not_called()


def test_no_requirements_file(runner):
"""
It should raise an error if there are no input files
Expand Down
2 changes: 1 addition & 1 deletion tests/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def test_sync_up_to_date(echo):
"""
Everything up-to-date should be printed.
"""
sync(set(), set())
sync(set(), set(), verbose=True)
echo.assert_called_once_with('Everything up-to-date')


Expand Down

0 comments on commit bc28e36

Please sign in to comment.