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


Python MagicMock.items方法代码示例

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


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

示例1: test_implicit_loop

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import items [as 别名]
 def test_implicit_loop(self):
     i1 = get_mock_item("type1", "name1", [], ["type1:name2"])
     i2 = get_mock_item("type1", "name2", [], ["type1:"])
     node = MagicMock()
     node.items = [i1, i2]
     with self.assertRaises(ItemDependencyError):
         list(apply_items(node))
开发者ID:bkendinibilir,项目名称:bundlewrap,代码行数:9,代码来源:node_tests.py

示例2: test_nested_loop

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import items [as 别名]
 def test_nested_loop(self):
     i1 = get_mock_item("type1", "name1", [], ["type1:name2"])
     i2 = get_mock_item("type1", "name2", [], ["type1:name3"])
     i3 = get_mock_item("type1", "name3", [], ["type1:name4"])
     i4 = get_mock_item("type1", "name4", [], ["type1:name1"])
     node = MagicMock()
     node.items = [i1, i2, i3, i4]
     with self.assertRaises(ItemDependencyError):
         list(apply_items(node))
开发者ID:bkendinibilir,项目名称:bundlewrap,代码行数:11,代码来源:node_tests.py

示例3: test_simple_order

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import items [as 别名]
    def test_simple_order(self):
        i1 = get_mock_item("type1", "name1", [], ["type1:name2"])
        i2 = get_mock_item("type1", "name2", [], ["type1:name3"])
        i3 = get_mock_item("type1", "name3", [], [])

        node = MagicMock()
        node.items = [i1, i2, i3]

        results = list(apply_items(node))

        self.assertEqual(results[0][0], "type1:name3")
        self.assertEqual(results[1][0], "type1:name2")
        self.assertEqual(results[2][0], "type1:name1")
开发者ID:bkendinibilir,项目名称:bundlewrap,代码行数:15,代码来源:node_tests.py

示例4: test_apply_interactive

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import items [as 别名]
    def test_apply_interactive(self):
        i1 = get_mock_item("type1", "name1", [], ["type1:name2"])
        i2 = get_mock_item("type1", "name2", [], ["type1:name3"])
        i3 = get_mock_item("type1", "name3", [], [])

        node = MagicMock()
        node.items = [i1, i2, i3]

        results = list(apply_items(node, interactive=True, profiling=True))

        self.assertEqual(results[0][0], "type1:name3")
        self.assertEqual(results[1][0], "type1:name2")
        self.assertEqual(results[2][0], "type1:name1")
开发者ID:bkendinibilir,项目名称:bundlewrap,代码行数:15,代码来源:node_tests.py

示例5: test_apply_parallel

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import items [as 别名]
    def test_apply_parallel(self):
        i1 = get_mock_item("type1", "name1", [], ["type1:name2"])
        i2 = get_mock_item("type1", "name2", [], ["type1:name3"])
        i3 = get_mock_item("type1", "name3", [], [])

        node = MagicMock()
        node.items = [i1, i2, i3]

        results = list(apply_items(node, workers=2))

        self.assertEqual(results[0][0], "type1:name3")
        self.assertEqual(results[1][0], "type1:name2")
        self.assertEqual(results[2][0], "type1:name1")
开发者ID:bkendinibilir,项目名称:bundlewrap,代码行数:15,代码来源:node_tests.py

示例6: setUp

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import items [as 别名]
    def setUp(self):
        item1 = MockItem("type1:item1")
        item2 = MockItem("type1:item2")
        item3 = MockItem("directory:/bar/baz")
        item4 = MockItem("file:/foo/47")
        item4.attributes = {'content_type': 'mako'}
        item5 = MockItem("file:/foo/48")
        item5.attributes = {'content_type': 'binary'}

        node = MagicMock()
        node.items = (item1, item2, item3, item4, item5)

        self.repo = MagicMock()
        self.repo.get_node.return_value = node

        self.tmpdir = mkdtemp()
        rmtree(self.tmpdir)
开发者ID:bkendinibilir,项目名称:bundlewrap,代码行数:19,代码来源:items_tests.py

示例7: test_output

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import items [as 别名]
    def test_output(self):
        class FakeItem1(Item):
            BUNDLE_ATTRIBUTE_NAME = "fakes1"
            ITEM_TYPE_NAME = "type1"

        class FakeItem2(Item):
            BUNDLE_ATTRIBUTE_NAME = "fakes1"
            ITEM_TYPE_NAME = "type2"

        class FakeItem3(Item):
            BUNDLE_ATTRIBUTE_NAME = "fakes1"
            ITEM_TYPE_NAME = "type3"

        class FakeBundle(object):
            bundle_dir = "/dev/null"
            bundle_data_dir = "/dev/null"
            node = None

        item1 = FakeItem1(FakeBundle(), "item1", {})
        item2 = FakeItem1(FakeBundle(), "item2", {})
        item3 = FakeItem2(FakeBundle(), "item1", {})
        item3.needs = ["type1:item1"]

        item4 = FakeItem3(FakeBundle(), "item1", {})
        item4.NEEDS_STATIC = ["type2:"]

        bundle1 = MagicMock()
        bundle1.name = "bundle1"
        bundle1.items = [item1, item2, item3]
        for item in bundle1.items:
            item.bundle = bundle1

        bundle2 = MagicMock()
        bundle2.name = "bundle2"
        bundle2.items = [item4]
        for item in bundle2.items:
            item.bundle = bundle2

        node = MagicMock()
        node.bundles = [bundle1, bundle2]
        node.items = [item1, item2, item3, item4]
        node.name = "node"

        args = {}
        args['node'] = "node"
        args['cluster'] = True
        args['depends_concurrency'] = True
        args['depends_static'] = True
        args['depends_regular'] = True
        args['depends_reverse'] = True
        args['depends_auto'] = True

        rep = MagicMock()
        rep.get_node.return_value = node

        self.assertEqual(
            "\n".join(list(plot.bw_plot_node(rep, args))),
            "digraph bundlewrap\n"
            "{\n"
            "rankdir = LR\n"
            "graph [color=\"#303030\"; fontname=Helvetica; penwidth=2; shape=box; style=\"rounded,dashed\"]\n"
            "node [color=\"#303030\"; fillcolor=\"#303030\"; fontcolor=white; fontname=Helvetica; shape=box; style=\"rounded,filled\"]\n"
            "edge [arrowhead=vee]\n"
            "subgraph cluster_0\n"
            "{\n"
            "label = \"bundle1\"\n"
            "\"bundle:bundle1\"\n"
            "\"type1:item1\"\n"
            "\"type1:item2\"\n"
            "\"type2:item1\"\n"
            "}\n"
            "subgraph cluster_1\n"
            "{\n"
            "label = \"bundle2\"\n"
            "\"bundle:bundle2\"\n"
            "\"type3:item1\"\n"
            "}\n"
            "\"bundle:bundle1\" -> \"type1:item1\" [color=\"#6BB753\",penwidth=2]\n"
            "\"bundle:bundle1\" -> \"type1:item2\" [color=\"#6BB753\",penwidth=2]\n"
            "\"bundle:bundle1\" -> \"type2:item1\" [color=\"#6BB753\",penwidth=2]\n"
            "\"bundle:bundle2\" -> \"type3:item1\" [color=\"#6BB753\",penwidth=2]\n"
            "\"type1:\" -> \"type1:item1\" [color=\"#6BB753\",penwidth=2]\n"
            "\"type1:\" -> \"type1:item2\" [color=\"#6BB753\",penwidth=2]\n"
            "\"type2:\" -> \"type2:item1\" [color=\"#6BB753\",penwidth=2]\n"
            "\"type2:item1\" -> \"type1:item1\" [color=\"#C24948\",penwidth=2]\n"
            "\"type3:\" -> \"type3:item1\" [color=\"#6BB753\",penwidth=2]\n"
            "\"type3:item1\" -> \"type2:\" [color=\"#3991CC\",penwidth=2]\n"
            "fontsize = 28\n"
            "label = \"node\"\n"
            "labelloc = \"t\"\n"
            "}",
        )
开发者ID:bkendinibilir,项目名称:bundlewrap,代码行数:94,代码来源:plot_tests.py


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