當前位置: 首頁>>代碼示例>>Python>>正文


Python click.__version__方法代碼示例

本文整理匯總了Python中click.__version__方法的典型用法代碼示例。如果您正苦於以下問題:Python click.__version__方法的具體用法?Python click.__version__怎麽用?Python click.__version__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在click的用法示例。


在下文中一共展示了click.__version__方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_cli_write_coverage

# 需要導入模塊: import click [as 別名]
# 或者: from click import __version__ [as 別名]
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 
開發者ID:Vimjas,項目名稱:covimerage,代碼行數:26,代碼來源:test_cli.py

示例2: _prefill_appinfo

# 需要導入模塊: import click [as 別名]
# 或者: from click import __version__ [as 別名]
def _prefill_appinfo(self):
        self['av'] = __version__

        # gather dependent packages
        dpdata = []
        dpdata.append("Click/%s" % click.__version__)
        if app.get_session_var("caller_id"):
            dpdata.append("Caller/%s" % app.get_session_var("caller_id"))
        try:
            result = util.exec_command(["scons", "--version"])
            match = re.search(r"engine: v([\d\.]+)", result['out'])
            if match:
                dpdata.append("SCons/%s" % match.group(1))
        except:  # pylint: disable=W0702
            pass
        self['an'] = " ".join(dpdata) 
開發者ID:bq,項目名稱:web2board,代碼行數:18,代碼來源:telemetry.py

示例3: test_cli_call

# 需要導入模塊: import click [as 別名]
# 或者: from click import __version__ [as 別名]
def test_cli_call(capfd):
    assert call(['covimerage', '--version']) == 0
    out, err = capfd.readouterr()
    assert out == get_version_message() + '\n'

    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 == '' 
開發者ID:Vimjas,項目名稱:covimerage,代碼行數:28,代碼來源:test_cli.py

示例4: test_report_profile_or_data_file

# 需要導入模塊: import click [as 別名]
# 或者: from click import __version__ [as 別名]
def test_report_profile_or_data_file(runner, tmpdir):
    from covimerage.cli import DEFAULT_COVERAGE_DATA_FILE

    result = runner.invoke(cli.main, [
        'report', '--data-file', '/does/not/exist'])
    assert result.output.splitlines()[-1] == \
        'Error: Invalid value for "--data-file": Could not open file: /does/not/exist: No such file or directory'
    assert result.exit_code == 2

    result = runner.invoke(cli.main, [
        'report', '--data-file', os.devnull])
    cov_exc = 'CoverageException: Doesn\'t seem to be a coverage.py data file'
    assert result.output.splitlines()[-1] == \
        'Error: Coverage could not read data_file: /dev/null (%s)' % cov_exc
    assert result.exit_code == 1

    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

    result = runner.invoke(cli.main, ['report', '/does/not/exist'])
    assert result.output.splitlines()[-1] == \
        'Error: Invalid value for "%s": Could not open file: /does/not/exist: No such file or directory' % (
            'profile_file' if click.__version__ < '7.0' else '[PROFILE_FILE]...',)
    assert result.exit_code == 2

    result = runner.invoke(cli.main, [
        '--rcfile', os.devnull,
        'report', 'tests/fixtures/merged_conditionals-0.profile'])
    assert result.output.splitlines() == [
        'Name                                        Stmts   Miss  Cover',
        '---------------------------------------------------------------',
        'tests/test_plugin/merged_conditionals.vim      19     12    37%']
    assert result.exit_code == 0 
開發者ID:Vimjas,項目名稱:covimerage,代碼行數:38,代碼來源:test_cli.py

示例5: test_run_cmd_requires_args

# 需要導入模塊: import click [as 別名]
# 或者: from click import __version__ [as 別名]
def test_run_cmd_requires_args(runner):
    result = runner.invoke(cli.run, [])
    assert 'Error: Missing argument "%s".' % (
        'args' if click.__version__ < '7.0' else 'ARGS...',
    ) in result.output.splitlines()
    assert result.exit_code == 2 
開發者ID:Vimjas,項目名稱:covimerage,代碼行數:8,代碼來源:test_cli.py

示例6: test_update_with_invalid_state

# 需要導入模塊: import click [as 別名]
# 或者: from click import __version__ [as 別名]
def test_update_with_invalid_state(
            self, mock_states, mock_show, mock_update):
        """Validate behavior with invalid state."""

        mock_states.return_value = ['foo']

        runner = CLIRunner()
        result = runner.invoke(patch.update_cmd, [
            '123', '--state', 'bar'])

        assert result.exit_code == 2, result
        if version.parse(click.__version__) >= version.Version('7.1'):
            assert "Invalid value for '--state'" in result.output, result
        else:
            assert 'Invalid value for "--state"' in result.output, result 
開發者ID:getpatchwork,項目名稱:git-pw,代碼行數:17,代碼來源:test_patch.py

示例7: collect_versions

# 需要導入模塊: import click [as 別名]
# 或者: from click import __version__ [as 別名]
def collect_versions() -> Generator[str, None, None]:
    yield f"- python {version_from_info(sys.version_info)}"
    yield f"- gd.py {version_from_info(gd.version_info)}"
    yield f"- aiohttp v{aiohttp.__version__}"
    yield f"- click v{click.__version__}"
    yield "- system {0.system} {0.release} {0.version}".format(platform.uname())


# run main 
開發者ID:NeKitDS,項目名稱:gd.py,代碼行數:11,代碼來源:__main__.py

示例8: cli

# 需要導入模塊: import click [as 別名]
# 或者: from click import __version__ [as 別名]
def cli(ctx, obj):
    """Show Alerta server and client versions."""
    client = obj['client']
    click.echo('alerta {}'.format(client.mgmt_status()['version']))
    click.echo('alerta client {}'.format(client_version))
    click.echo('requests {}'.format(requests_version))
    click.echo('click {}'.format(click.__version__))
    ctx.exit() 
開發者ID:alerta,項目名稱:python-alerta-client,代碼行數:10,代碼來源:cmd_version.py

示例9: write_man_pages

# 需要導入模塊: import click [as 別名]
# 或者: from click import __version__ [as 別名]
def write_man_pages(name, cli, parent_ctx=None, version=None, target_dir=None):
    """
    Generate man page files recursively
    for the given click cli function.

    :param str name: the cli name
    :param cli: the cli instance
    :param click.Context parent_ctx: the parent click context
    :param str target_dir: the directory where the generated
                           man pages are stored.
    """
    ctx = click.Context(cli, info_name=name, parent=parent_ctx)

    man_page = generate_man_page(ctx, version)
    path = '{0}.1'.format(ctx.command_path.replace(' ', '-'))
    if target_dir:
        path = os.path.join(target_dir, path)

    with open(path, 'w+') as f:
        f.write(man_page)

    commands = getattr(cli, 'commands', {})
    for name, command in commands.items():
        if LooseVersion(click.__version__) >= LooseVersion("7.0"):
            # Since Click 7.0, we have been able to mark commands as hidden
            if command.hidden:
                # Do not write a man page for a hidden command
                continue
        write_man_pages(name, command, parent_ctx=ctx, version=version, target_dir=target_dir) 
開發者ID:click-contrib,項目名稱:click-man,代碼行數:31,代碼來源:core.py

示例10: test_report_source

# 需要導入模塊: import click [as 別名]
# 或者: from click import __version__ [as 別名]
def test_report_source(runner, tmpdir, devnull):
    with tmpdir.as_cwd():
        result = runner.invoke(cli.main, ["report", "--source", ".", "/does/not/exist"])
        assert (
            result.output.splitlines()[-1]
            == 'Error: Invalid value for "%s": Could not open file: /does/not/exist: No such file or directory' % (
                'profile_file' if click.__version__ < '7.0' else '[PROFILE_FILE]...',)
        )
        assert result.exit_code == 2

        fname = "foo/bar/test.vim"
        tmpdir.join(fname).ensure().write("echom 1")
        tmpdir.join("foo/bar/test2.vim").ensure().write("echom 2")
        result = runner.invoke(cli.main, ["report", "--source", ".", devnull.name])
        out = result.output.splitlines()
        assert any(l.startswith(fname) for l in out)  # pragma: no branch
        assert out[-1].startswith("TOTAL")
        assert out[-1].endswith(" 0%")
        assert result.exit_code == 0

        result = runner.invoke(cli.main, ["report", devnull.name, "--source", "."])
        out = result.output.splitlines()
        assert any(fname in l for l in out)  # pragma: no branch
        assert out[-1].startswith("TOTAL")
        assert out[-1].endswith(" 0%")
        assert result.exit_code == 0

        result = runner.invoke(cli.main, ["report", "--source", "."])
        out = result.output.splitlines()
        assert out[-1] == "Error: --source can only be used with PROFILE_FILE."
        assert result.exit_code == 2

    result = runner.invoke(
        cli.main,
        [
            "--rcfile",
            devnull.name,
            "report",
            "--source",
            "tests/test_plugin/merged_conditionals.vim",
            "tests/fixtures/merged_conditionals-0.profile",
        ],
    )
    assert (
        result.output.splitlines()
        == [
            "Name                                        Stmts   Miss  Cover",
            "---------------------------------------------------------------",
            "tests/test_plugin/merged_conditionals.vim      19     12    37%",
        ]
    )
    assert result.exit_code == 0 
開發者ID:Vimjas,項目名稱:covimerage,代碼行數:54,代碼來源:test_cli.py


注:本文中的click.__version__方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。