Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show less output on sync with quiet option #765

Merged
merged 1 commit into from
Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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