当前位置: 首页>>代码示例>>Python>>正文


Python flexmock.flexmock方法代码示例

本文整理汇总了Python中flexmock.flexmock方法的典型用法代码示例。如果您正苦于以下问题:Python flexmock.flexmock方法的具体用法?Python flexmock.flexmock怎么用?Python flexmock.flexmock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flexmock的用法示例。


在下文中一共展示了flexmock.flexmock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: pypi

# 需要导入模块: import flexmock [as 别名]
# 或者: from flexmock import flexmock [as 别名]
def pypi(self, tmpdir):
        conf = Configuration()
        path = str(tmpdir)
        src = Path(__file__).parent / "src/rlsbot-test"
        shutil.copy2(str(src / "setup.py"), path)
        shutil.copy2(str(src / "rlsbot_test.py"), path)
        self.run_cmd("git init .", work_directory=str(tmpdir))
        set_git_credentials(str(tmpdir), "Release Bot", "bot@example.com")
        self.run_cmd("git add .", work_directory=str(tmpdir))
        self.run_cmd("git commit -m 'initial commit'", work_directory=str(tmpdir))
        git_repo = Git(str(tmpdir), conf)
        pypi = PyPi(configuration, git_repo)
        (flexmock(pypi)
         .should_receive("upload")
         .replace_with(lambda x: None))
        return pypi 
开发者ID:user-cont,项目名称:release-bot,代码行数:18,代码来源:test_pypi.py

示例2: test_load_configuration_merges_include

# 需要导入模块: import flexmock [as 别名]
# 或者: from flexmock import flexmock [as 别名]
def test_load_configuration_merges_include():
    builtins = flexmock(sys.modules['builtins'])
    builtins.should_receive('open').with_args('include.yaml').and_return(
        '''
        foo: bar
        baz: quux
        '''
    )
    builtins.should_receive('open').with_args('config.yaml').and_return(
        '''
        foo: override
        <<: !include include.yaml
        '''
    )

    assert module.load_configuration('config.yaml') == {'foo': 'override', 'baz': 'quux'} 
开发者ID:witten,项目名称:borgmatic,代码行数:18,代码来源:test_load.py

示例3: test_parse_subparser_arguments_consumes_subparser_arguments_with_alias

# 需要导入模块: import flexmock [as 别名]
# 或者: from flexmock import flexmock [as 别名]
def test_parse_subparser_arguments_consumes_subparser_arguments_with_alias():
    action_namespace = flexmock(foo=True)
    action_subparser = flexmock(parse_known_args=lambda arguments: (action_namespace, []))
    subparsers = flexmock(
        choices={
            'action': action_subparser,
            '-a': action_subparser,
            'other': flexmock(),
            '-o': flexmock(),
        }
    )
    flexmock(module).SUBPARSER_ALIASES = {'action': ['-a'], 'other': ['-o']}

    arguments = module.parse_subparser_arguments(('-a', '--foo', 'true'), subparsers)

    assert arguments == {'action': action_namespace} 
开发者ID:witten,项目名称:borgmatic,代码行数:18,代码来源:test_arguments.py

示例4: test_parse_subparser_arguments_consumes_multiple_subparser_arguments

# 需要导入模块: import flexmock [as 别名]
# 或者: from flexmock import flexmock [as 别名]
def test_parse_subparser_arguments_consumes_multiple_subparser_arguments():
    action_namespace = flexmock(foo=True)
    other_namespace = flexmock(bar=3)
    subparsers = flexmock(
        choices={
            'action': flexmock(
                parse_known_args=lambda arguments: (action_namespace, ['--bar', '3'])
            ),
            'other': flexmock(parse_known_args=lambda arguments: (other_namespace, [])),
        }
    )

    arguments = module.parse_subparser_arguments(
        ('action', '--foo', 'true', 'other', '--bar', '3'), subparsers
    )

    assert arguments == {'action': action_namespace, 'other': other_namespace} 
开发者ID:witten,项目名称:borgmatic,代码行数:19,代码来源:test_arguments.py

示例5: test_parse_global_arguments_with_help_does_not_apply_default_subparsers

# 需要导入模块: import flexmock [as 别名]
# 或者: from flexmock import flexmock [as 别名]
def test_parse_global_arguments_with_help_does_not_apply_default_subparsers():
    global_namespace = flexmock(verbosity='lots')
    action_namespace = flexmock()
    top_level_parser = flexmock(parse_args=lambda arguments: global_namespace)
    subparsers = flexmock(
        choices={
            'action': flexmock(
                parse_known_args=lambda arguments: (action_namespace, ['--verbosity', 'lots'])
            ),
            'other': flexmock(),
        }
    )

    arguments = module.parse_global_arguments(
        ('--verbosity', 'lots', '--help'), top_level_parser, subparsers
    )

    assert arguments == global_namespace 
开发者ID:witten,项目名称:borgmatic,代码行数:20,代码来源:test_arguments.py

示例6: test_parse_global_arguments_consumes_global_arguments_before_subparser_name

# 需要导入模块: import flexmock [as 别名]
# 或者: from flexmock import flexmock [as 别名]
def test_parse_global_arguments_consumes_global_arguments_before_subparser_name():
    global_namespace = flexmock(verbosity='lots')
    action_namespace = flexmock()
    top_level_parser = flexmock(parse_args=lambda arguments: global_namespace)
    subparsers = flexmock(
        choices={
            'action': flexmock(
                parse_known_args=lambda arguments: (action_namespace, ['--verbosity', 'lots'])
            ),
            'other': flexmock(),
        }
    )

    arguments = module.parse_global_arguments(
        ('--verbosity', 'lots', 'action'), top_level_parser, subparsers
    )

    assert arguments == global_namespace 
开发者ID:witten,项目名称:borgmatic,代码行数:20,代码来源:test_arguments.py

示例7: test_parse_global_arguments_consumes_global_arguments_after_subparser_name

# 需要导入模块: import flexmock [as 别名]
# 或者: from flexmock import flexmock [as 别名]
def test_parse_global_arguments_consumes_global_arguments_after_subparser_name():
    global_namespace = flexmock(verbosity='lots')
    action_namespace = flexmock()
    top_level_parser = flexmock(parse_args=lambda arguments: global_namespace)
    subparsers = flexmock(
        choices={
            'action': flexmock(
                parse_known_args=lambda arguments: (action_namespace, ['--verbosity', 'lots'])
            ),
            'other': flexmock(),
        }
    )

    arguments = module.parse_global_arguments(
        ('action', '--verbosity', 'lots'), top_level_parser, subparsers
    )

    assert arguments == global_namespace 
开发者ID:witten,项目名称:borgmatic,代码行数:20,代码来源:test_arguments.py

示例8: test_execute_command_calls_full_command

# 需要导入模块: import flexmock [as 别名]
# 或者: from flexmock import flexmock [as 别名]
def test_execute_command_calls_full_command():
    full_command = ['foo', 'bar']
    flexmock(module.os, environ={'a': 'b'})
    flexmock(module.subprocess).should_receive('Popen').with_args(
        full_command,
        stdin=None,
        stdout=module.subprocess.PIPE,
        stderr=module.subprocess.STDOUT,
        shell=False,
        env=None,
        cwd=None,
    ).and_return(flexmock(stdout=None)).once()
    flexmock(module).should_receive('log_outputs')

    output = module.execute_command(full_command)

    assert output is None 
开发者ID:witten,项目名称:borgmatic,代码行数:19,代码来源:test_execute.py

示例9: test_execute_command_calls_full_command_with_output_file

# 需要导入模块: import flexmock [as 别名]
# 或者: from flexmock import flexmock [as 别名]
def test_execute_command_calls_full_command_with_output_file():
    full_command = ['foo', 'bar']
    output_file = flexmock(name='test')
    flexmock(module.os, environ={'a': 'b'})
    flexmock(module.subprocess).should_receive('Popen').with_args(
        full_command,
        stdin=None,
        stdout=output_file,
        stderr=module.subprocess.PIPE,
        shell=False,
        env=None,
        cwd=None,
    ).and_return(flexmock(stderr=None)).once()
    flexmock(module).should_receive('log_outputs')

    output = module.execute_command(full_command, output_file=output_file)

    assert output is None 
开发者ID:witten,项目名称:borgmatic,代码行数:20,代码来源:test_execute.py

示例10: test_execute_command_calls_full_command_with_input_file

# 需要导入模块: import flexmock [as 别名]
# 或者: from flexmock import flexmock [as 别名]
def test_execute_command_calls_full_command_with_input_file():
    full_command = ['foo', 'bar']
    input_file = flexmock(name='test')
    flexmock(module.os, environ={'a': 'b'})
    flexmock(module.subprocess).should_receive('Popen').with_args(
        full_command,
        stdin=input_file,
        stdout=module.subprocess.PIPE,
        stderr=module.subprocess.STDOUT,
        shell=False,
        env=None,
        cwd=None,
    ).and_return(flexmock(stdout=None)).once()
    flexmock(module).should_receive('log_outputs')

    output = module.execute_command(full_command, input_file=input_file)

    assert output is None 
开发者ID:witten,项目名称:borgmatic,代码行数:20,代码来源:test_execute.py

示例11: test_execute_command_calls_full_command_with_extra_environment

# 需要导入模块: import flexmock [as 别名]
# 或者: from flexmock import flexmock [as 别名]
def test_execute_command_calls_full_command_with_extra_environment():
    full_command = ['foo', 'bar']
    flexmock(module.os, environ={'a': 'b'})
    flexmock(module.subprocess).should_receive('Popen').with_args(
        full_command,
        stdin=None,
        stdout=module.subprocess.PIPE,
        stderr=module.subprocess.STDOUT,
        shell=False,
        env={'a': 'b', 'c': 'd'},
        cwd=None,
    ).and_return(flexmock(stdout=None)).once()
    flexmock(module).should_receive('log_outputs')

    output = module.execute_command(full_command, extra_environment={'c': 'd'})

    assert output is None 
开发者ID:witten,项目名称:borgmatic,代码行数:19,代码来源:test_execute.py

示例12: test_execute_command_calls_full_command_with_working_directory

# 需要导入模块: import flexmock [as 别名]
# 或者: from flexmock import flexmock [as 别名]
def test_execute_command_calls_full_command_with_working_directory():
    full_command = ['foo', 'bar']
    flexmock(module.os, environ={'a': 'b'})
    flexmock(module.subprocess).should_receive('Popen').with_args(
        full_command,
        stdin=None,
        stdout=module.subprocess.PIPE,
        stderr=module.subprocess.STDOUT,
        shell=False,
        env=None,
        cwd='/working',
    ).and_return(flexmock(stdout=None)).once()
    flexmock(module).should_receive('log_outputs')

    output = module.execute_command(full_command, working_directory='/working')

    assert output is None 
开发者ID:witten,项目名称:borgmatic,代码行数:19,代码来源:test_execute.py

示例13: test_execute_command_without_run_to_completion_returns_process

# 需要导入模块: import flexmock [as 别名]
# 或者: from flexmock import flexmock [as 别名]
def test_execute_command_without_run_to_completion_returns_process():
    full_command = ['foo', 'bar']
    process = flexmock()
    flexmock(module.os, environ={'a': 'b'})
    flexmock(module.subprocess).should_receive('Popen').with_args(
        full_command,
        stdin=None,
        stdout=module.subprocess.PIPE,
        stderr=module.subprocess.STDOUT,
        shell=False,
        env=None,
        cwd=None,
    ).and_return(process).once()
    flexmock(module).should_receive('log_outputs')

    assert module.execute_command(full_command, run_to_completion=False) == process 
开发者ID:witten,项目名称:borgmatic,代码行数:18,代码来源:test_execute.py

示例14: test_execute_command_with_processes_calls_full_command

# 需要导入模块: import flexmock [as 别名]
# 或者: from flexmock import flexmock [as 别名]
def test_execute_command_with_processes_calls_full_command():
    full_command = ['foo', 'bar']
    processes = (flexmock(),)
    flexmock(module.os, environ={'a': 'b'})
    flexmock(module.subprocess).should_receive('Popen').with_args(
        full_command,
        stdin=None,
        stdout=module.subprocess.PIPE,
        stderr=module.subprocess.STDOUT,
        shell=False,
        env=None,
        cwd=None,
    ).and_return(flexmock(stdout=None)).once()
    flexmock(module).should_receive('log_outputs')

    output = module.execute_command_with_processes(full_command, processes)

    assert output is None 
开发者ID:witten,项目名称:borgmatic,代码行数:20,代码来源:test_execute.py

示例15: test_execute_command_with_processes_calls_full_command_with_output_file

# 需要导入模块: import flexmock [as 别名]
# 或者: from flexmock import flexmock [as 别名]
def test_execute_command_with_processes_calls_full_command_with_output_file():
    full_command = ['foo', 'bar']
    processes = (flexmock(),)
    output_file = flexmock(name='test')
    flexmock(module.os, environ={'a': 'b'})
    flexmock(module.subprocess).should_receive('Popen').with_args(
        full_command,
        stdin=None,
        stdout=output_file,
        stderr=module.subprocess.PIPE,
        shell=False,
        env=None,
        cwd=None,
    ).and_return(flexmock(stderr=None)).once()
    flexmock(module).should_receive('log_outputs')

    output = module.execute_command_with_processes(full_command, processes, output_file=output_file)

    assert output is None 
开发者ID:witten,项目名称:borgmatic,代码行数:21,代码来源:test_execute.py


注:本文中的flexmock.flexmock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。