當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。