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


Python Mock.settings方法代码示例

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


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

示例1: test_coldfusion_formatter_fill_custom_options

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import settings [as 别名]
def test_coldfusion_formatter_fill_custom_options(
    coldfusionbeautifier, options
):

    fake_options = type('fake_obj', (object,), {})
    coldfusionbeautifier.default_options = Mock(return_value=fake_options)
    from codeformatter.coldfusionformatter import ColdfusionFormatter

    mocked_formatter = Mock()
    curr_options = {}
    for k, v in options:
        curr_options[k] = v

    mocked_formatter.settings = {
        'codeformatter_coldfusion_options': curr_options}

    ColdfusionFormatter(mocked_formatter)
    keys_tested = []
    for k, v in options:
        assert getattr(fake_options, k) == v
        keys_tested.append(k)
    for key, _ in options_to_test:
        if key in keys_tested:
            continue
        assert not getattr(fake_options, key, None)
开发者ID:akalongman,项目名称:sublimetext-codeformatter,代码行数:27,代码来源:test_coldfusionformatter.py

示例2: testBuild_namespace

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import settings [as 别名]
 def testBuild_namespace(self):
     file_path = ['folder1','folder2','src','folder3','folder4','test.php']
     settings = Mock()
     settings.get = Mock(return_value=['src','tests'])
     view = Mock()
     view.settings = Mock(return_value=settings)
     view.file_name = Mock(return_value=os.sep.join(file_path))
     assert build_namespace(view) == 'folder3\\folder4'
开发者ID:Brandon0,项目名称:dotfiles,代码行数:10,代码来源:test_namespaces.py

示例3: test_coldfusion_formatter_format_empty_exception

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import settings [as 别名]
def test_coldfusion_formatter_format_empty_exception(coldfusionbeautifier):

    coldfusionbeautifier.beautify = Mock(side_effect=Exception(''))
    from codeformatter.coldfusionformatter import ColdfusionFormatter

    mocked_formatter = Mock()
    mocked_formatter.settings = {'codeformatter_coldfusion_options': {}}

    input_text = 'test'.encode('utf8')
    cff = ColdfusionFormatter(mocked_formatter)

    out, err = cff.format(input_text)
    assert out == ''
    assert err == 'Formatting error!'
开发者ID:akalongman,项目名称:sublimetext-codeformatter,代码行数:16,代码来源:test_coldfusionformatter.py

示例4: test_coldfusion_formatter_format_on_save_enabled

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import settings [as 别名]
def test_coldfusion_formatter_format_on_save_enabled(
    coldfusionbeautifier, options, filename, expected
):

    fake_options = type('fake_obj', (object,), {})
    coldfusionbeautifier.default_options = Mock(return_value=fake_options)
    from codeformatter.coldfusionformatter import ColdfusionFormatter

    mocked_formatter = Mock()
    mocked_formatter.settings = {'codeformatter_coldfusion_options': options}

    cff = ColdfusionFormatter(mocked_formatter)
    res = cff.format_on_save_enabled(filename)
    assert res is expected
开发者ID:akalongman,项目名称:sublimetext-codeformatter,代码行数:16,代码来源:test_coldfusionformatter.py

示例5: test_coldfusion_formatter_instance_creation

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import settings [as 别名]
def test_coldfusion_formatter_instance_creation(coldfusionbeautifier):

    coldfusionbeautifier.default_options = Mock(
        return_value={'singer': 'nina'})
    from codeformatter.coldfusionformatter import ColdfusionFormatter

    mocked_formatter = Mock()
    mocked_formatter.settings = {
        'codeformatter_coldfusion_options': 'feeling good'}

    with patch.object(ColdfusionFormatter, 'fill_custom_options'):
        cff = ColdfusionFormatter(mocked_formatter)
        assert cff.formatter == mocked_formatter
        assert cff.options == {'singer': 'nina'}
        cff.fill_custom_options.assert_called_once_with('feeling good')
开发者ID:akalongman,项目名称:sublimetext-codeformatter,代码行数:17,代码来源:test_coldfusionformatter.py

示例6: test_css_formatter_instance_creation

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import settings [as 别名]
def test_css_formatter_instance_creation(cssbeautifier):

    cssbeautifier.default_options = Mock(
        return_value={'band': 'beatles'})
    from codeformatter.cssformatter import CssFormatter

    mocked_formatter = Mock()
    mocked_formatter.settings = {
        'codeformatter_css_options': 'a day in the life'}

    with patch.object(CssFormatter, 'fill_custom_options'):
        cf = CssFormatter(mocked_formatter)
        assert cf.formatter == mocked_formatter
        assert cf.options == {'band': 'beatles'}
        cf.fill_custom_options.assert_called_once_with('a day in the life')
开发者ID:akalongman,项目名称:sublimetext-codeformatter,代码行数:17,代码来源:test_cssformatter.py

示例7: test_css_formatter_format_exception

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import settings [as 别名]
def test_css_formatter_format_exception(cssbeautifier):

    cssbeautifier.beautify = Mock(
        side_effect=Exception('looks like it failed'))
    from codeformatter.cssformatter import CssFormatter

    mocked_formatter = Mock()
    mocked_formatter.settings = {'codeformatter_css_options': {}}

    input_text = 'test'.encode('utf8')
    cff = CssFormatter(mocked_formatter)

    out, err = cff.format(input_text)
    assert out == ''
    assert err == 'looks like it failed'
开发者ID:akalongman,项目名称:sublimetext-codeformatter,代码行数:17,代码来源:test_cssformatter.py

示例8: test_coldfusion_formatter_format

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import settings [as 别名]
def test_coldfusion_formatter_format(coldfusionbeautifier):

    coldfusionbeautifier.default_options = Mock(return_value={})
    coldfusionbeautifier.beautify = Mock(return_value='beautified text')
    from codeformatter.coldfusionformatter import ColdfusionFormatter

    mocked_formatter = Mock()
    mocked_formatter.settings = {'codeformatter_coldfusion_options': {}}

    input_text = 'test'.encode('utf8')
    cff = ColdfusionFormatter(mocked_formatter)
    out, err = cff.format(input_text)

    assert coldfusionbeautifier.beautify.called_with(
        call(input_text.decode('utf-8'), {}))
    assert out == 'beautified text'
    assert err == ''
开发者ID:akalongman,项目名称:sublimetext-codeformatter,代码行数:19,代码来源:test_coldfusionformatter.py

示例9: test_css_formatter_format

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import settings [as 别名]
def test_css_formatter_format(cssbeautifier):

    cssbeautifier.default_options = Mock(return_value={})
    cssbeautifier.beautify = Mock(return_value='graham nash')
    from codeformatter.cssformatter import CssFormatter

    mocked_formatter = Mock()
    mocked_formatter.settings = {'codeformatter_css_options': {}}

    input_text = 'test'.encode('utf8')
    cff = CssFormatter(mocked_formatter)
    out, err = cff.format(input_text)

    assert cssbeautifier.beautify.called_with(
        call(input_text.decode('utf-8'), {}))
    assert out == 'graham nash'
    assert err == ''
开发者ID:akalongman,项目名称:sublimetext-codeformatter,代码行数:19,代码来源:test_cssformatter.py

示例10: test_css_formatter_fill_custom_options_partialy

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import settings [as 别名]
def test_css_formatter_fill_custom_options_partialy(
    cssbeautifier, key, value, expected, not_used_scenarios
):

    fake_options = type('fake_obj', (object,), {})
    cssbeautifier.default_options = Mock(return_value=fake_options)
    from codeformatter.cssformatter import CssFormatter

    mocked_formatter = Mock()
    curr_options = {}
    curr_options[key] = value

    mocked_formatter.settings = {'codeformatter_css_options': curr_options}

    CssFormatter(mocked_formatter)
    assert getattr(fake_options, key) == expected
    for key, expected in not_used_scenarios:
        assert getattr(fake_options, key, None) == expected
开发者ID:akalongman,项目名称:sublimetext-codeformatter,代码行数:20,代码来源:test_cssformatter.py

示例11: test_css_formatter_fill_custom_options_full

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import settings [as 别名]
def test_css_formatter_fill_custom_options_full(
    cssbeautifier, full_options
):
    fake_options = type('fake_obj', (object,), {})
    cssbeautifier.default_options = Mock(return_value=fake_options)
    from codeformatter.cssformatter import CssFormatter

    mocked_formatter = Mock()
    curr_values = {}
    curr_expected = []
    for key, value, expected in full_options:
        curr_values[key] = value
        curr_expected.append((key, expected))

    mocked_formatter.settings = {'codeformatter_css_options': curr_values}

    CssFormatter(mocked_formatter)
    for key, expected in curr_expected:
        assert getattr(fake_options, key, None) == expected
开发者ID:akalongman,项目名称:sublimetext-codeformatter,代码行数:21,代码来源:test_cssformatter.py


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