How to use the covimerage.cli.main function in covimerage

To help you get started, we’ve selected a few covimerage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Vimjas / covimerage / tests / test_logging.py View on Github external
level_name = level.upper()
        assert m.call_args_list[-1] == mocker.call(level_name)

    # -v should not override -l.
    m.reset_mock()
    result = runner.invoke(cli.main, [
            '-l', 'warning', '-vvv',
            'report', '--nonexistingoption'])
    assert_output(result)
    assert result.exit_code == 2
    assert m.call_args_list == [mocker.call('WARNING')]

    # -q should not override -l.
    m.reset_mock()
    result = runner.invoke(cli.main, [
            '-l', 'warning', '-qqq',
            'report', '--nonexistingoption'])
    assert_output(result)
    assert result.exit_code == 2
    assert m.call_args_list == [mocker.call('WARNING')]
github Vimjas / covimerage / tests / test_cli.py View on Github external
def test_report_missing_data_file(runner, tmpdir):
    from covimerage.cli import DEFAULT_COVERAGE_DATA_FILE

    with tmpdir.as_cwd():
        result = runner.invoke(cli.main, ['report'])
        assert result.output.splitlines()[-1] == \
            'Error: Invalid value for "--data-file": Could not open file: %s: No such file or directory' % (
                DEFAULT_COVERAGE_DATA_FILE)
        assert result.exit_code == 2
github Vimjas / covimerage / tests / test_logging.py View on Github external
'',
                'Error: no such option: --nonexistingoption']

    for level in ['error', 'warning', 'info', 'debug']:
        result = runner.invoke(cli.main, [
            '--loglevel', level,
            'report', '--nonexistingoption'])
        assert_output(result)
        assert result.exit_code == 2

        level_name = level.upper()
        assert m.call_args_list[-1] == mocker.call(level_name)

    # -v should not override -l.
    m.reset_mock()
    result = runner.invoke(cli.main, [
            '-l', 'warning', '-vvv',
            'report', '--nonexistingoption'])
    assert_output(result)
    assert result.exit_code == 2
    assert m.call_args_list == [mocker.call('WARNING')]

    # -q should not override -l.
    m.reset_mock()
    result = runner.invoke(cli.main, [
            '-l', 'warning', '-qqq',
            'report', '--nonexistingoption'])
    assert_output(result)
    assert result.exit_code == 2
    assert m.call_args_list == [mocker.call('WARNING')]
github Vimjas / covimerage / tests / test_cli.py View on Github external
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(
                str(old_dir), 'tests/fixtures/conditional_function.profile')])
        assert excinfo.value.code == 0
        assert os.path.exists(DEFAULT_COVERAGE_DATA_FILE)

    result = runner.invoke(cli.main, ['write_coverage', '/does/not/exist'])
    if click.__version__ < '7.0':
        assert result.output.splitlines()[-1].startswith(
            '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:')
    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