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


Python flexmock函数代码示例

本文整理汇总了Python中flexmock函数的典型用法代码示例。如果您正苦于以下问题:Python flexmock函数的具体用法?Python flexmock怎么用?Python flexmock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: test_pull_base_base_parse

def test_pull_base_base_parse(reactor_config_map, inspect_only):  # noqa
    flexmock(ImageName).should_receive('parse').and_raise(AttributeError)
    with pytest.raises(AttributeError):
        test_pull_base_image_plugin(LOCALHOST_REGISTRY, BASE_IMAGE, [BASE_IMAGE_W_REGISTRY],
                                    [BASE_IMAGE_W_LIB_REG],
                                    reactor_config_map=reactor_config_map,
                                    inspect_only=inspect_only)
开发者ID:projectatomic,项目名称:atomic-reactor,代码行数:7,代码来源:test_pull_base_image.py

示例2: test_create_simple_session

    def test_create_simple_session(self):
        url = 'https://koji-hub-url.com'
        session = flexmock()

        (flexmock(koji_util.koji)
            .should_receive('ClientSession').with_args(url).and_return(session))
        assert create_koji_session(url) == session
开发者ID:digideskio,项目名称:atomic-reactor,代码行数:7,代码来源:test_koji_util.py

示例3: prepare

    def prepare(self, workflow):
        # Setup expected platforms
        workflow.buildstep_plugins_conf[0]['args']['platforms'] = ['x86_64', 'ppc64le']
        workflow.prebuild_results[PLUGIN_CHECK_AND_SET_PLATFORMS_KEY] = set(['x86_64', 'ppc64le'])

        # Setup platform descriptors
        workflow.plugin_workspace[ReactorConfigPlugin.key][WORKSPACE_CONF_KEY] =\
            ReactorConfig({
                'version': 1,
                'source_registry': {'url': 'registry.example.com', 'insecure': True},
                'platform_descriptors': [{'platform': 'x86_64', 'architecture': 'amd64'}],
            })

        # Setup multi-arch manifest list
        manifest_list = {
            'manifests': [
                {'platform': {'architecture': 'amd64'}, 'digest': 'sha256:123456'},
                {'platform': {'architecture': 'ppc64le'}, 'digest': 'sha256:654321'},
            ]
        }
        (flexmock(atomic_reactor.util)
         .should_receive('get_manifest_list')
         .and_return(flexmock(json=lambda: manifest_list,
                              content=json.dumps(manifest_list).encode('utf-8'))))

        return workflow
开发者ID:projectatomic,项目名称:atomic-reactor,代码行数:26,代码来源:test_pull_base_image.py

示例4: test_unknown_product

  def test_unknown_product(self):
    catalog = flexmock(find_price = lambda _: None)
    display = flexmock()
    sale_controller = SaleController(catalog, display)

    display.should_receive("display_product_not_found_message").with_args("12345").once

    sale_controller.on_barcode("12345")
开发者ID:bereal,项目名称:PointOfSale-Python,代码行数:8,代码来源:sell_one_item_test.py

示例5: test_empty_barcode

  def test_empty_barcode(self):
    catalog = flexmock()
    display = flexmock()
    sale_controller = SaleController(catalog, display)

    display.should_receive("display_empty_barcode_message").once

    sale_controller.on_barcode("")
开发者ID:bereal,项目名称:PointOfSale-Python,代码行数:8,代码来源:sell_one_item_test.py

示例6: test_create_authenticated_session

    def test_create_authenticated_session(self):
        url = 'https://koji-hub-url.com'
        session = flexmock()
        session.should_receive('krb_login').once().and_return(True)

        (flexmock(koji_util.koji)
            .should_receive('ClientSession').with_args(url).and_return(session))
        assert create_koji_session(url, {}) == session
开发者ID:digideskio,项目名称:atomic-reactor,代码行数:8,代码来源:test_koji_util.py

示例7: getOpenMock

 def getOpenMock():
     """
     Mocks FileUtils to return a mock, and returns
     that mock from this function so you can run
     expectations on it, etc.
     """
     fileMock = flexmock()
     flexmock(FileUtils).should_receive("open").and_return(fileMock)
     return fileMock
开发者ID:CarlosManriquez,项目名称:NTRTsim,代码行数:9,代码来源:mock_helpers.py

示例8: test_context_manager_on_instance

 def test_context_manager_on_instance(self):
   class CM(object):
     def __enter__(self): pass
     def __exit__(self, *_): pass
   cm = CM()
   flexmock(cm).should_call('__enter__').once
   flexmock(cm).should_call('__exit__').once
   with cm: pass
   self._tear_down()
开发者ID:FoxLisk,项目名称:flexmock,代码行数:9,代码来源:flexmock_modern_test.py

示例9: test_context_manager_on_class

 def test_context_manager_on_class(self):
   class CM(object):
     def __enter__(self): pass
     def __exit__(self, *_): pass
   cm = CM()
   flexmock(CM).should_receive('__enter__').once
   flexmock(CM).should_receive('__exit__').once
   with cm: pass
   self._tear_down()
开发者ID:FoxLisk,项目名称:flexmock,代码行数:9,代码来源:flexmock_modern_test.py

示例10: test_known_product

  def test_known_product(self):
    price = Price.euro(12)
    catalog = flexmock(find_price = lambda _: price)
    display = flexmock()
    sale_controller = SaleController(catalog, display)

    display.should_receive("display_price").with_args(price).once

    sale_controller.on_barcode("12345")
开发者ID:bereal,项目名称:PointOfSale-Python,代码行数:9,代码来源:sell_one_item_test.py

示例11: test_builtin_open

 def test_builtin_open(self):
     if sys.version_info < (3, 0):
         mock = flexmock(sys.modules['__builtin__'])
     else:
         mock = flexmock(sys.modules['builtins'])
     fake_fd = flexmock(read=lambda: 'some data')
     mock.should_receive('open').once.with_args('file_name').and_return(fake_fd)
     with open('file_name') as f:
         data = f.read()
     self.assertEqual('some data', data)
开发者ID:bkabrda,项目名称:flexmock,代码行数:10,代码来源:flexmock_modern_test.py

示例12: workflow_callback

 def workflow_callback(workflow):
     workflow = self.prepare(workflow)
     manifest_list = {
         'manifests': [
             {'platform': {'architecture': 'amd64'}, 'digest': 'sha256:123456'},
         ]
     }
     (flexmock(atomic_reactor.util)
      .should_receive('get_manifest_list')
      .and_return(flexmock(json=lambda: manifest_list)))
     return workflow
开发者ID:projectatomic,项目名称:atomic-reactor,代码行数:11,代码来源:test_pull_base_image.py

示例13: test_daemon

def test_daemon(config_dir):
    args = flexmock(config_dir=config_dir.strpath,
                    foreground=True,
                    verbose=True)

    d = flexmock(daemon)
    d.should_receive('_parse_arguments').and_return(args)
    d.should_receive('_check_privileges')

    k = flexmock(KnockWatcher)
    k.should_receive('tail_and_process')

    d.main()
开发者ID:peick,项目名称:knockknock,代码行数:13,代码来源:test_daemon.py

示例14: test_tagging

    def test_tagging(self, task_state, failure):
        session = flexmock()
        task_id = 9876
        build_id = 1234
        target_name = 'target'
        tag_name = 'images-candidate'
        target_info = {'dest_tag_name': tag_name}
        task_info = {'state': koji.TASK_STATES[task_state]}

        (session
            .should_receive('getBuildTarget')
            .with_args(target_name)
            .and_return(target_info))
        (session
            .should_receive('tagBuild')
            .with_args(tag_name, build_id)
            .and_return(task_id))
        (session
            .should_receive('taskFinished')
            .with_args(task_id)
            .and_return(True))
        (session
            .should_receive('getTaskInfo')
            .with_args(task_id, request=True)
            .and_return(task_info))

        if failure:
            with pytest.raises(RuntimeError):
                tag_koji_build(session, build_id, target_name)
        else:
            build_tag = tag_koji_build(session, build_id, target_name)
            assert build_tag == tag_name
开发者ID:vrutkovs,项目名称:atomic-reactor,代码行数:32,代码来源:test_koji_util.py

示例15: test_log_encoding

    def test_log_encoding(self, caplog, monkeypatch):
        if MOCK:
            mock_docker()

        (flexmock(InputPluginsRunner)
            .should_receive('run')
            .and_raise(RuntimeError))

        monkeypatch.setenv('LC_ALL', 'en_US.UTF-8')
        command = [
            "main.py",
            "--verbose",
            "inside-build",
        ]
        with caplog.atLevel(logging.INFO):
            with pytest.raises(RuntimeError):
                self.exec_cli(command)

        # first message should be 'log encoding: <encoding>'
        match = caplog.records()[0].message.split(':')
        if not match:
            raise RuntimeError

        encoding = codecs.getreader(match[1])
        assert encoding == encodings.utf_8.StreamReader
开发者ID:vrutkovs,项目名称:atomic-reactor,代码行数:25,代码来源:test_cli.py


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