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


Python Mocker.count方法代码示例

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


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

示例1: test_pyccuracy_core_run_tests_works_when_None_Result_returned_from_story_runner

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import count [as 别名]
def test_pyccuracy_core_run_tests_works_when_None_Result_returned_from_story_runner():
    
    mocker = Mocker()
    
    context_mock, fso_mock = make_context_and_fso_mocks(mocker)
    context_mock.settings.write_report
    mocker.result(False)
        
    suite_mock = mocker.mock()
    suite_mock.no_story_header
    mocker.result([])
    suite_mock.stories
    mocker.result(['some story'])

    runner_mock = mocker.mock()
    parser_mock = mocker.mock()
    parser_mock.used_actions
    mocker.count(min=1, max=None)
    mocker.result([])

    parser_mock.get_stories(ANY)
    mocker.result(suite_mock)
    runner_mock.run_stories(KWARGS)
    mocker.result(None)

    with mocker:
        pc = PyccuracyCore(parser_mock, runner_mock)
    
        assert pc.run_tests(should_throw=False, context=context_mock, fso=fso_mock) == None
开发者ID:Desperado,项目名称:pyccuracy,代码行数:31,代码来源:test_core.py

示例2: test_execute_action_will_not_execute_itself

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import count [as 别名]
def test_execute_action_will_not_execute_itself():

    mocker = Mocker()

    class DoSomethingRecursiveAction(ActionBase):
        regex = r'^(And )?I do "(?P<what>\w+)" stuff$'

        def execute(self, context, getter_mock, *args, **kwargs):
            self.execute_action('And I do "recursive" stuff', context, getter=getter_mock)

    language_getter_mock = mocker.mock()
    language_getter_mock.get(ANY)
    mocker.count(min=1, max=None)
    mocker.result("^$")

    context_mock = Object(settings=mocker.mock())
    context_mock.settings.default_culture
    mocker.result("en-us")

    with mocker:
        dosaction = DoSomethingRecursiveAction()
        args = []
        kwargs = dict(what="nothing")

        dosaction.execute(context_mock, getter_mock=language_getter_mock, *args, **kwargs)
开发者ID:heynemann,项目名称:pyccuracy,代码行数:27,代码来源:test_actions.py

示例3: test_find_match_matched

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import count [as 别名]
    def test_find_match_matched(self):
        key = "chr1:154000-230000"
        mocker = Mocker()

        junction = mocker.mock()
        junction.coverage
        mocker.result(40)
        mocker.count(1, None)

        container = mocker.mock()
        container.keys()
        mocker.result([key])

        container[key]
        mocker.result(junction)
        mocker.count(1, None)

        mocker.replay()

        self.common, self.diff = jc.findMatch(container, container)
        self.assertEqual(self.common.keys(), ["chr1:154000-230000"])
        self.assertEqual(self.diff.keys(), [])

        mocker.restore()
        mocker.verify()
开发者ID:bjventers,项目名称:python-codes-for-RNAseq,代码行数:27,代码来源:test_junction_comp.py

示例4: test_find_match_not_matched

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import count [as 别名]
    def test_find_match_not_matched(self):
        key1 = "chr1:154000-230000"
        mocker = Mocker()

        junction = mocker.mock()
        junction.coverage
        mocker.result(40)

        container1 = mocker.mock()
        container2 = mocker.mock()

        container1.keys()
        mocker.result([key1])

        container1[key1]
        mocker.result(junction)

        container2[key1]
        mocker.throw(KeyError)
        mocker.count(1)

        mocker.replay()

        self.common, self.diff = jc.findMatch(container1, container2)
        self.assertEqual(self.common.keys(), [])
        self.assertEqual(self.diff.keys(), [key1])

        mocker.restore()
        mocker.verify()
开发者ID:bjventers,项目名称:python-codes-for-RNAseq,代码行数:31,代码来源:test_junction_comp.py

示例5: test_offset

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import count [as 别名]
    def test_offset(self):
        """
        Test that, if the server's BEGIN_CONTENT message specifies an offset,
        the file to be uploaded is seek'ed to the right position.
        """
        offset = 23
        mocker = Mocker()
        transport = mocker.mock()
        transport.registerProducer(ANY, streaming=True)
        transport.write(ANY)
        mocker.count(1, None)  # I don't really care how many times
        fd = mocker.mock()
        fd.seek(offset)  # this is really all I care about
        fd.read(ANY)
        mocker.result('')
        mocker.replay()

        protocol = StorageClient()
        protocol.transport = transport
        pc = PutContent(protocol, 'share', 'node', '', '', 0, 0, 0, fd)
        message = protocol_pb2.Message()
        message.type = protocol_pb2.Message.BEGIN_CONTENT
        message.begin_content.offset = offset
        pc.start()
        pc.processMessage(message)
开发者ID:magicicada-bot,项目名称:magicicada-protocol,代码行数:27,代码来源:test_putcontent.py

示例6: test_server_start_stop_metrics

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import count [as 别名]
    def test_server_start_stop_metrics(self):
        """Test start/stop metrics."""
        mocker = Mocker()

        service_meter = mocker.mock(name='meter')
        self.service.metrics = service_meter

        revno = mocker.mock(name='revno')
        self.patch(metrics.services, 'revno', revno)

        service_meter.meter('server_stop')
        service_meter.decrement('services_active')
        service_meter.meter('server_start')
        service_meter.increment('services_active')

        service_meter.timing("busy.ping", ANY)
        mocker.count(0, None)

        revno()
        mocker.count(0, None)

        service_meter.connection
        mocker.result(None)

        with mocker:
            yield self.service.stopService()
            yield self.service.startService()
开发者ID:CSRedRat,项目名称:magicicada-server,代码行数:29,代码来源:test_basic.py

示例7: setUpZope

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import count [as 别名]
    def setUpZope(self, app, configurationContext):
        # Mock postmonkey
        mocker = Mocker()
        postmonkey = mocker.replace("postmonkey")
        mailchimp = postmonkey.PostMonkey(ANY)
        mocker.count(0, 1000)
        # Lists
        mailchimp.lists()
        mocker.count(0, 1000)
        mocker.result({
            u'total': 2,
            u'data': [{
                    u'id': 625,
                    u'web_id': 625,
                    u'name': u'ACME Newsletter',
                    u'default_from_name': u'[email protected]',
                },
                {
                    u'id': 626,
                    u'web_id': 626,
                    u'name': u'ACME Newsletter 2',
                    u'default_from_name': u'[email protected]',
                },
            ]})
        mocker.replay()

        # Load ZCML
        import example.tdd
        xmlconfig.file(
            'configure.zcml',
            example.tdd,
            context=configurationContext
        )
开发者ID:tisto,项目名称:example.tdd,代码行数:35,代码来源:testing.py

示例8: test_pyccuracy_core_run_tests

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import count [as 别名]
def test_pyccuracy_core_run_tests():
    mocker = Mocker()
    context_mock, fso_mock = make_context_and_fso_mocks(mocker)
    context_mock.settings.write_report
    mocker.result(False)

    suite_mock = mocker.mock()
    suite_mock.no_story_header
    mocker.result([])
    suite_mock.stories
    mocker.result(['some story'])

    runner_mock = mocker.mock()
    parser_mock = mocker.mock()
    parser_mock.used_actions
    mocker.count(min=1, max=None)
    mocker.result([])
    
    results_mock = mocker.mock()
    results_mock.summary_for('en-us')
    mocker.result('my results')
    
    parser_mock.get_stories(ANY)
    mocker.result(suite_mock)
    runner_mock.run_stories(KWARGS)
    mocker.result(results_mock)
    
    with mocker:
        pc = PyccuracyCore(parser_mock, runner_mock)
    
        #TODO: falha
        results = pc.run_tests(should_throw=False, context=context_mock, fso=fso_mock)
        assert results == results_mock, results
开发者ID:Desperado,项目名称:pyccuracy,代码行数:35,代码来源:test_core.py

示例9: test_init_with_serial

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import count [as 别名]
def test_init_with_serial():
    m = Mocker()
    kvo_class = m.replace(mod, 'KVOList')
    deserialize = m.method(Project.deserialize)
    reset_cache = m.method(Project.reset_serial_cache)
    docs = kvo_class.alloc().init() >> []
    deserialize("<serial>")
    reset_cache(); m.count(2)
    with m:
        proj = Project.alloc().init_with_serial("<serial>")
开发者ID:khairy,项目名称:editxt,代码行数:12,代码来源:test_project.py

示例10: test_healthcheck_returns_204_if_the_mysql_server_is_on

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import count [as 别名]
 def test_healthcheck_returns_204_if_the_mysql_server_is_on(self):
     mocker = Mocker()
     obj = mocker.replace("mysqlapi.api.models.DatabaseManager.is_up")
     obj()
     mocker.result(True)
     mocker.count(1, 2)
     mocker.replay()
     request = RequestFactory().get("/resources/g8mysql/status/")
     view = Healthcheck()
     fake = mocks.FakeEC2Client()
     view._client = fake
     response = view.get(request, "g8mysql")
     self.assertEqual(204, response.status_code)
     mocker.verify()
开发者ID:agnhesi,项目名称:mysqlapi,代码行数:16,代码来源:test_healthcheck.py

示例11: test_wait_for_disappear_works_even_when_is_visible_raises

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import count [as 别名]
def test_wait_for_disappear_works_even_when_is_visible_raises():
    
    mocker = Mocker()
    
    context = Context(Settings())
    selenium_mock = mocker.mock()
    selenium_mock.is_element_present('some element')
    mocker.count(min=1, max=None)
    mocker.result(True)
    selenium_mock.is_visible('some element')
    mocker.throw(Exception("ERROR: Element some element not found"))

    with mocker:
        driver = SeleniumDriver(context, selenium=selenium_mock)
        driver.wait_for_element_to_disappear("some element", 1)
开发者ID:Desperado,项目名称:pyccuracy,代码行数:17,代码来源:test_selenium_browser_driver.py

示例12: test_wait_for_disappear

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import count [as 别名]
def test_wait_for_disappear():
    
    mocker = Mocker()
    
    context = Context(Settings())
    selenium_mock = mocker.mock()
    selenium_mock.is_element_present('some element')
    mocker.count(min=1, max=None)
    mocker.result(True)
    selenium_mock.is_visible('some element')
    mocker.count(min=1, max=None)
    mocker.result(True)

    with mocker:
        driver = SeleniumDriver(context, selenium=selenium_mock)
        driver.wait_for_element_to_disappear("some element", 1)
开发者ID:Desperado,项目名称:pyccuracy,代码行数:18,代码来源:test_selenium_browser_driver.py

示例13: test_action_registry_suitable_for_raises_when_language_getter_can_not_resolve

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import count [as 别名]
def test_action_registry_suitable_for_raises_when_language_getter_can_not_resolve():

    mocker = Mocker()

    class MyActionLanguage(ActionBase):
        regex = LanguageItem("foo_bar_regex1")

        def execute(self, context, *args, **kw):
            pass

    language_getter_mock = mocker.mock()
    language_getter_mock.get(LanguageItem("foo_bar_regex1"))
    mocker.result(None)
    language_getter_mock.get(ANY)
    mocker.count(min=1, max=None)
    mocker.result("^$")

    with mocker:
        Action, args, kwargs = ActionRegistry.suitable_for("Something blabla", "en-us", getter=language_getter_mock)
开发者ID:heynemann,项目名称:pyccuracy,代码行数:21,代码来源:test_actions.py

示例14: test_action_registry_suitable_for_returns_my_action

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import count [as 别名]
def test_action_registry_suitable_for_returns_my_action():

    mocker = Mocker()

    class MyAction(ActionBase):
        regex = LanguageItem("foo_bar_regex")

        def execute(self, context, *args, **kw):
            pass

    language_getter_mock = mocker.mock()
    language_getter_mock.get(LanguageItem("foo_bar_regex"))
    mocker.result("My regex .+")
    language_getter_mock.get(ANY)
    mocker.count(min=1, max=None)
    mocker.result("^$")

    with mocker:
        Action, args, kwargs = ActionRegistry.suitable_for("My regex baz", "en-us", getter=language_getter_mock)
        assert Action is MyAction
开发者ID:heynemann,项目名称:pyccuracy,代码行数:22,代码来源:test_actions.py

示例15: test_action_registry_suitable_for_returns_my_action_without_language_item

# 需要导入模块: from mocker import Mocker [as 别名]
# 或者: from mocker.Mocker import count [as 别名]
def test_action_registry_suitable_for_returns_my_action_without_language_item():

    mocker = Mocker()

    class MyActionNoLanguage(ActionBase):
        regex = r"^I do (\w+)\s(\w+) so proudly$"

        def execute(self, context, *args, **kw):
            pass

    language_getter_mock = mocker.mock()
    language_getter_mock.get(ANY)
    mocker.count(min=1, max=None)
    mocker.result("^$")

    with mocker:
        Action, args, kwargs = ActionRegistry.suitable_for(
            "I do unit test so proudly", "en-us", getter=language_getter_mock
        )
        assert Action is MyActionNoLanguage
开发者ID:heynemann,项目名称:pyccuracy,代码行数:22,代码来源:test_actions.py


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