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


Python PropertyMock.assert_called_with方法代码示例

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


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

示例1: test_change_colorbar_config

# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import assert_called_with [as 别名]
    def test_change_colorbar_config(self):
        view_colorbar_range_mock = PropertyMock()
        view_colorbar_log_mock = PropertyMock()
        type(self.view).colorbar_range = view_colorbar_range_mock
        type(self.view).colorbar_log = view_colorbar_log_mock

        model_colorbar_range_mock = PropertyMock(return_value=(1, 5))
        model_colorbar_log_mock = PropertyMock(return_value=False)
        type(self.model).colorbar_range = model_colorbar_range_mock
        type(self.model).colorbar_log = model_colorbar_log_mock

        # passed model -> view
        self.presenter = SlicePlotOptionsPresenter(self.view, self.model)

        model_colorbar_range_mock.assert_called_with()
        model_colorbar_log_mock.assert_called_with()
        view_colorbar_range_mock.assert_called_once_with((1, 5))
        view_colorbar_log_mock.assert_called_once_with(False)

        # passed view -> model
        view_colorbar_range_mock.return_value = (2, 10)
        view_colorbar_log_mock.return_value = True
        self.presenter._set_c_range()
        self.presenter._set_colorbar_log()
        self.presenter.get_new_config()
        self.model.change_axis_scale.assert_called_once_with((2, 10), True)
开发者ID:mantidproject,项目名称:mslice,代码行数:28,代码来源:plot_options_presenter_test.py

示例2: test_get_keyring_success

# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import assert_called_with [as 别名]
    def test_get_keyring_success(self):
        key = "key"
        tsigsecret = "secret"

        conf_m = self.create_patch("yandex_designate.backend.dynamicdns.cfg.CONF")
        read_tsigkey_m = self.create_patch("yandex_designate.backend.dynamicdns.read_tsigkey")
        parse_tsigkeyring_m = self.create_patch("dns.tsigkeyring.from_text")
        keyfile = Mock()
        config = Mock()
        keyring_m = Mock()
        key_m = PropertyMock(return_value=key)
        keyfile_m = PropertyMock(return_value=keyfile)

        type(config).dyndns_key = key_m
        type(config).dyndns_key_file = keyfile_m
        conf_m.__getitem__.return_value = config
        read_tsigkey_m.return_value = ("md5", tsigsecret)
        parse_tsigkeyring_m.return_value = keyring_m

        self.assertEqual(get_keyring(), keyring_m)

        key_m.assert_called_with()
        keyfile_m.assert_called_with()
        read_tsigkey_m.assert_called_with(keyfile, key)
        parse_tsigkeyring_m.assert_called_with({key: tsigsecret})
开发者ID:mudrykaa,项目名称:designate-dyn-dns-backend,代码行数:27,代码来源:test_dynamic_dns_backend.py

示例3: test_change_xrange

# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import assert_called_with [as 别名]
    def test_change_xrange(self):

        view_x_range_mock = PropertyMock()
        type(self.view).x_range = view_x_range_mock

        model_x_range_mock = PropertyMock(return_value=(1, 5))
        type(self.model).x_range = model_x_range_mock

        # passed model -> view
        self.presenter1 = SlicePlotOptionsPresenter(self.view, self.model)

        model_x_range_mock.assert_called_with()
        view_x_range_mock.assert_called_once_with((1, 5))

        # passed view -> model through slice presenter
        model_x_range_mock.reset_mock()
        view_x_range_mock.return_value = (2, 10)
        self.presenter1._xy_config_modified('x_range')
        self.presenter1.get_new_config()
        model_x_range_mock.assert_called_once_with((2, 10))

        # passed view -> model through cut presenter
        self.presenter2 = CutPlotOptionsPresenter(self.view, self.model)
        self.presenter2._xy_config_modified('x_range')
        self.presenter2.get_new_config()
        self.model.change_axis_scale.assert_called_once()
开发者ID:mantidproject,项目名称:mslice,代码行数:28,代码来源:plot_options_presenter_test.py

示例4: test_is_supported

# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import assert_called_with [as 别名]
    def test_is_supported(self):

        input_mock = PropertyMock(return_value="coffee")

        class IsSupportedTestCompiler(BaseCompiler):
            input_extension = input_mock

        compiler = IsSupportedTestCompiler()
        self.assertEqual(compiler.is_supported("dummy.coffee"), True)
        self.assertEqual(compiler.is_supported("dummy.js"), False)
        input_mock.assert_called_with()
开发者ID:Anber,项目名称:django-static-precompiler,代码行数:13,代码来源:test_base_compiler.py

示例5: test_get_output_filename

# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import assert_called_with [as 别名]
    def test_get_output_filename(self):

        input_mock = PropertyMock(return_value="coffee")
        output_mock = PropertyMock(return_value="js")

        class GetOutputFilenameTestCompiler(BaseCompiler):
            input_extension = input_mock
            output_extension = output_mock

        compiler = GetOutputFilenameTestCompiler()
        self.assertEqual(
            compiler.get_output_filename("dummy.coffee"),
            "dummy.js"
        )
        self.assertEqual(
            compiler.get_output_filename("dummy.coffee.coffee"),
            "dummy.coffee.js"
        )
        input_mock.assert_called_with()
        output_mock.assert_called_with()
开发者ID:Anber,项目名称:django-static-precompiler,代码行数:22,代码来源:test_base_compiler.py

示例6: test_get_keyring_fail_on_parse

# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import assert_called_with [as 别名]
    def test_get_keyring_fail_on_parse(self):
        key = "key"
        tsigsecret = "secret"

        conf_m = self.create_patch("yandex_designate.backend.dynamicdns.cfg.CONF")
        read_tsigkey_m = self.create_patch("yandex_designate.backend.dynamicdns.read_tsigkey")
        parse_tsigkeyring_m = self.create_patch("dns.tsigkeyring.from_text")
        keyfile = Mock()
        config = Mock()
        key_m = PropertyMock(return_value=key)
        keyfile_m = PropertyMock(return_value=keyfile)

        type(config).dyndns_key = key_m
        type(config).dyndns_key_file = keyfile_m
        conf_m.__getitem__.return_value = config
        read_tsigkey_m.return_value = ("md5", tsigsecret)
        parse_tsigkeyring_m.side_effect = binascii.Error

        self.assertRaises(TsigKeyError, get_keyring)

        key_m.assert_called_with()
        keyfile_m.assert_called_with()
        read_tsigkey_m.assert_called_with(keyfile, key)
        parse_tsigkeyring_m.assert_called_with({key: tsigsecret})
开发者ID:mudrykaa,项目名称:designate-dyn-dns-backend,代码行数:26,代码来源:test_dynamic_dns_backend.py

示例7: test_is_element_displayed_splinter

# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import assert_called_with [as 别名]
    def test_is_element_displayed_splinter(self, page, splinter, splinter_strategy):
        locator = (splinter_strategy, str(random.random()))

        from mock import PropertyMock

        visible_mock = PropertyMock(return_value=True)
        page.driver.configure_mock(
            **{
                "find_by_{0}.return_value.first.visible".format(
                    splinter_strategy
                ): visible_mock
            }
        )
        type(
            getattr(
                page.driver, "find_by_{0}".format(splinter_strategy)
            ).return_value.first
        ).visible = visible_mock
        assert Region(page).is_element_displayed(*locator)

        getattr(
            page.driver, "find_by_{0}".format(splinter_strategy)
        ).assert_called_once_with(locator[1])
        visible_mock.assert_called_with()
开发者ID:davehunt,项目名称:PyPOM,代码行数:26,代码来源:test_region.py


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