Beispiel #1
0
def test_get_version_message_importerror(monkeypatch_importerror):
    exc = ImportError('failed')
    with monkeypatch_importerror(('coverage', ), raise_exc=exc):
        assert get_version_message() == (
            'covimerage, version %s (using Coverage.py unknown (failed))' %
            (get_version(), ))
    exc = ImportError
    with monkeypatch_importerror(('coverage', ), raise_exc=exc):
        assert get_version_message() == (
            'covimerage, version %s (using Coverage.py unknown ())' %
            (get_version(), ))
Beispiel #2
0
def test_cli_call(capfd):
    assert call(['covimerage', '--version']) == 0
    out, err = capfd.readouterr()
    assert out == 'covimerage, version %s\n' % get_version()

    assert call(['covimerage', '--help']) == 0
    out, err = capfd.readouterr()
    assert out.startswith('Usage:')

    assert call(['covimerage', 'file not found']) == 2
    out, err = capfd.readouterr()
    err_lines = err.splitlines()
    assert err_lines[0] == 'Usage: covimerage [OPTIONS] COMMAND [ARGS]...'
    # click after 6.7 (9cfea14) includes: 'Try "covimerage --help" for help.'
    assert err_lines[-2:] == ['', 'Error: No such command "file not found".']
    assert out == ''

    assert call(['covimerage', 'write_coverage', 'file not found']) == 2
    out, err = capfd.readouterr()
    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]...", ))
    assert out == ''
Beispiel #3
0
def test_dunder_main_run_help(capfd):
    assert call([sys.executable, '-m', 'covimerage', '--version']) == 0
    out, err = capfd.readouterr()
    lines = out.splitlines()
    assert len(lines) == 1
    assert lines[0].startswith('covimerage, version %s' % get_version())
Beispiel #4
0
def test_cli_version(arg, runner):
    result = runner.invoke(cli.main, [arg])
    assert result.output == 'covimerage, version %s\n' % get_version()
    assert result.exit_code == 0
Beispiel #5
0
def test_dunder_main_run_help(capfd):
    assert call([sys.executable, '-m', 'covimerage', '--version']) == 0
    out, err = capfd.readouterr()
    assert out == 'covimerage, version %s\n' % get_version()