Skip to content

Commit

Permalink
Merge pull request #83 from blueyed/write_coverage_profile_file_required
Browse files Browse the repository at this point in the history
write_coverage: PROFILE_FILE is required
  • Loading branch information
blueyed authored Oct 4, 2019
2 parents a6ffeb7 + b446e98 commit 83018f3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
14 changes: 11 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ common: &common
bash <(curl -s https://codecov.io/bash) -Z -X gcov -X coveragepy -X search -X xcode -X gcovout -X fix -f coverage.xml -F "${CIRCLE_JOB//-/,}"
# Coveralls and Codacy do not support merged reports.
if [[ "$CIRCLE_JOB" == py36 ]]; then
if [[ "$CIRCLE_JOB" != py37-coveragepy5 ]]; then
# coveralls-python does not work with Coverage.py 5's data yet.
# (https://github.com/coveralls-clients/coveralls-python/issues/203)
pip install coveralls
coveralls
COVERALLS_PARALLEL=true coveralls
fi
# Coveralls and Codacy do not support merged reports.
if [[ "$CIRCLE_JOB" == py36 ]]; then
pip install codacy-coverage
python-codacy-coverage --verbose --report coverage.xml
fi
Expand Down Expand Up @@ -95,3 +99,7 @@ workflows:
- py34
- py27
- checkqa

notify:
webhooks:
- url: https://coveralls.io/webhook?repo_token=$COVERALLS_REPO_TOKEN
2 changes: 1 addition & 1 deletion covimerage/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def main(ctx, verbose, quiet, loglevel, rcfile):


@main.command(name='write_coverage')
@click.argument('profile_file', type=click.File('r'), required=False, nargs=-1)
@click.argument('profile_file', type=click.File('r'), required=True, nargs=-1)
@click.option('--data-file', required=False, type=click.Path(dir_okay=False),
default=DEFAULT_COVERAGE_DATA_FILE,
help=('DATA_FILE to write into. '
Expand Down
13 changes: 10 additions & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_dunder_main_run_help(capfd):
assert lines[0].startswith('covimerage, version %s' % get_version())


def test_cli(runner, tmpdir):
def test_cli_write_coverage(runner, tmpdir):
with tmpdir.as_cwd() as old_dir:
with pytest.raises(SystemExit) as excinfo:
cli.write_coverage([os.path.join(
Expand All @@ -41,8 +41,15 @@ def test_cli(runner, tmpdir):
'Error: Invalid value for "profile_file": Could not open file:')
else:
assert result.output.splitlines()[-1].startswith(
'Error: Invalid value for "[PROFILE_FILE]...": Could not open file:')
'Error: Invalid value for "PROFILE_FILE...": Could not open file:')
assert result.exit_code == 2

result = runner.invoke(cli.main, ['write_coverage'])
if click.__version__ < '7.0':
expected = 'Error: Missing argument "profile_file".'
else:
expected = 'Error: Missing argument "PROFILE_FILE...".'
assert result.output.splitlines()[-1] == expected
assert result.exit_code == 2


Expand Down Expand Up @@ -306,7 +313,7 @@ def test_cli_call(capfd):
err_lines = err.splitlines()
assert err_lines[-1] == (
'Error: Invalid value for "%s": Could not open file: file not found: No such file or directory' % (
"profile_file" if click.__version__ < '7.0' else "[PROFILE_FILE]...",))
"profile_file" if click.__version__ < '7.0' else "PROFILE_FILE...",))
assert out == ''


Expand Down

0 comments on commit 83018f3

Please sign in to comment.