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


Python MagicMock.path方法代码示例

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


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

示例1: test_search

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import path [as 别名]
 def test_search(self, search):
     search.return_value = (("foo", "foodesc"),)
     repo = MagicMock()
     repo.path = "/dev/null"
     self.assertEqual(
         list(bw_repo_plugin_search(repo, MagicMock())),
         ["foo: foodesc"],
     )
开发者ID:bkendinibilir,项目名称:bundlewrap,代码行数:10,代码来源:repo_tests.py

示例2: test_list

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import path [as 别名]
 def test_list(self, listmethod):
     listmethod.return_value = (("foo", 1),)
     repo = MagicMock()
     repo.path = "/dev/null"
     self.assertEqual(
         list(bw_repo_plugin_list(repo, MagicMock())),
         ["foo (v1)"],
     )
开发者ID:bkendinibilir,项目名称:bundlewrap,代码行数:10,代码来源:repo_tests.py

示例3: _request

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import path [as 别名]
 def _request(self, args='hello', headers='world', path='/',
              method='GET'):
     request = MagicMock()
     request.args.get.return_value = args
     request.headers.get.return_value = headers
     request.method = method
     request.path = path
     request.start_time = time()
     return request
开发者ID:clouserw,项目名称:universal-search-recommendation,代码行数:11,代码来源:test_middleware.py

示例4: test_paginate_returns_this_paginator

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import path [as 别名]
    def test_paginate_returns_this_paginator(self):
        request = MagicMock()
        request.GET.get.return_value = 1
        request.GET.urlencode.return_value = ''
        request.path = ''

        qs = Addon.search()
        pager = paginate(request, qs)
        assert isinstance(pager.paginator, ESPaginator)
开发者ID:diox,项目名称:olympia,代码行数:11,代码来源:test_pagination.py

示例5: test_unknown_plugin

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import path [as 别名]
 def test_unknown_plugin(self, install):
     install.side_effect = NoSuchPlugin
     repo = MagicMock()
     repo.path = "/dev/null"
     args = {}
     args['force'] = False
     args['plugin'] = "foo"
     self.assertEqual(
         list(bw_repo_plugin_install(repo, args)),
         ["unknown plugin 'foo'", 1],
     )
开发者ID:bkendinibilir,项目名称:bundlewrap,代码行数:13,代码来源:repo_tests.py

示例6: test_single_update

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import path [as 别名]
 def test_single_update(self, update):
     update.return_value = (1, 2)
     repo = MagicMock()
     repo.path = "/dev/null"
     args = {
         'check_only': False,
         'force': False,
         'plugin': "foo",
     }
     self.assertEqual(
         list(bw_repo_plugin_update(repo, args)),
         ["foo: 1 → 2"],
     )
开发者ID:bkendinibilir,项目名称:bundlewrap,代码行数:15,代码来源:repo_tests.py

示例7: _create_storage_mock

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import path [as 别名]
def _create_storage_mock():
    storage_mock = MagicMock(spec=Storage, name='StorageMock')

    storage_mock.path = MagicMock(name='path')
    storage_mock.save = MagicMock(name='save')
    storage_mock.open = MagicMock(name="open")
    storage_mock.open.return_value = MagicMock(name='read')
    storage_mock.open.return_value.read = MagicMock(name='read')

    storage_mock.save.return_value = 'dummy.gif'
    storage_mock.path.return_value = 'dummy.gif'
    storage_mock.open.return_value.read.return_value = DUMMY_CONTENT
    return storage_mock
开发者ID:kklimonda,项目名称:coomix,代码行数:15,代码来源:mocks.py

示例8: test_all_update

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import path [as 别名]
 def test_all_update(self, update, listmethod):
     update.return_value = (1, 2)
     listmethod.return_value = (("foo", 1),)
     repo = MagicMock()
     repo.path = "/dev/null"
     args = {
         'check_only': False,
         'force': False,
         'plugin': None,
     }
     self.assertEqual(
         list(bw_repo_plugin_update(repo, args)),
         ["foo: 1 → 2"],
     )
开发者ID:bkendinibilir,项目名称:bundlewrap,代码行数:16,代码来源:repo_tests.py

示例9: test_active_with_not_matched_pattern

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import path [as 别名]
 def test_active_with_not_matched_pattern(self):
     '''
     activeタグのpatternが現在のURLとマッチしないとき、空白文字を返す
     '''
     t = Template(
         """{% load utils %}"""
         """{% active pattern %}"""
     )
     request = MagicMock()
     request.path = '/projects/giginet/'
     c = Context({
         'request':  request,
         'pattern': '^/members/.+/$'
     })
     render = t.render(c)
     self.assertEqual(render, '')
开发者ID:fordream,项目名称:Kawaz3rd,代码行数:18,代码来源:test_utils.py

示例10: test_active_contains_get_parameter

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import path [as 别名]
 def test_active_contains_get_parameter(self):
     """
     activeタグはGETパラメータの値も含む
     """
     t = Template(
         """{% load utils %}"""
         """{% active pattern %}"""
     )
     request = MagicMock()
     request.path = '/members/?o=username$'
     c = Context({
         'request':  request,
         'pattern': '.+?o=username'
     })
     render = t.render(c)
     self.assertEqual(render, 'active')
开发者ID:fordream,项目名称:Kawaz3rd,代码行数:18,代码来源:test_utils.py

示例11: test_active

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import path [as 别名]
 def test_active(self):
     '''
     activeタグのpatternが現在のURLとマッチしたとき、activeの文字を返す
     '''
     t = Template(
         """{% load utils %}"""
         """{% active pattern %}"""
     )
     request = MagicMock()
     request.path = '/members/giginet/'
     c = Context({
         'request':  request,
         'pattern': '^/members/.+/$'
     })
     render = t.render(c)
     self.assertEqual(render, 'active')
开发者ID:fordream,项目名称:Kawaz3rd,代码行数:18,代码来源:test_utils.py

示例12: test_ok

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import path [as 别名]
 def test_ok(self, PluginManager):
     node1 = FakeNode()
     repo_obj = MagicMock()
     repo_obj.nodes = (node1,)
     repo_obj.path = "/dev/null"
     args = {}
     args['item_workers'] = 4
     args['node_workers'] = 1
     args['plugin_conflict_error'] = True
     args['target'] = None
     pm = MagicMock()
     pm.list.return_value = (
         ("foo", 1),
     )
     pm.local_modifications.return_value = ()
     PluginManager.return_value = pm
     list(test.bw_test(repo_obj, args))
开发者ID:bkendinibilir,项目名称:bundlewrap,代码行数:19,代码来源:test_tests.py

示例13: test_interactive

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import path [as 别名]
    def test_interactive(self, interact):
        args = {}
        args['command'] = None
        args['node'] = None
        repo_obj = MagicMock()
        repo_obj.path = "/dev/null"
        repo_obj_validated = MagicMock()
        with patch(
                'bundlewrap.cmdline.debug.Repository',
                return_value=repo_obj_validated,
        ) as repo_class:
            debug.bw_debug(repo_obj, args)

            repo_class.assert_called_with(repo_obj.path)
            interact.assert_called_with(
                debug.DEBUG_BANNER,
                local={'repo': repo_obj_validated},
            )
开发者ID:bkendinibilir,项目名称:bundlewrap,代码行数:20,代码来源:debug_tests.py

示例14: test_interactive_node

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import path [as 别名]
 def test_interactive_node(self, interact):
     args = {}
     args['node'] = "node1"
     args['command'] = None
     args['itemid'] = None
     node = MagicMock()
     node.name = args['node']
     repo_obj = MagicMock()
     repo_obj.path = "/dev/null"
     repo_obj_validated = MagicMock()
     repo_obj_validated.get_node = MagicMock(return_value=node)
     with patch(
             'bundlewrap.cmdline.debug.Repository',
             return_value=repo_obj_validated,
     ):
         debug.bw_debug(repo_obj, args)
         interact.assert_called_with(
             debug.DEBUG_BANNER_NODE,
             local={
                 'node': node,
                 'repo': repo_obj_validated,
             },
         )
开发者ID:bkendinibilir,项目名称:bundlewrap,代码行数:25,代码来源:debug_tests.py


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