当前位置: 首页>>代码示例>>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;未经允许,请勿转载。