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


Python Plugins.load_plugins方法代码示例

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


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

示例1: test_importing_and_configuring_more_than_one

# 需要导入模块: from coverage.control import Plugins [as 别名]
# 或者: from coverage.control.Plugins import load_plugins [as 别名]
    def test_importing_and_configuring_more_than_one(self):
        self.make_file("plugin1.py", """\
            from coverage import CoveragePlugin

            class Plugin(CoveragePlugin):
                def __init__(self, options):
                    super(Plugin, self).__init__(options)
                    self.this_is = "me"
            """)
        self.make_file("plugin2.py", """\
            from coverage import CoveragePlugin

            class Plugin(CoveragePlugin):
                pass
            """)

        config = FakeConfig("plugin1", {'a': 'hello'})
        plugins = list(Plugins.load_plugins(["plugin1", "plugin2"], config))

        self.assertEqual(len(plugins), 2)
        self.assertEqual(plugins[0].this_is, "me")
        self.assertEqual(plugins[0].options, {'a': 'hello'})
        self.assertEqual(plugins[1].options, {})
        self.assertEqual(config.asked_for, ['plugin1', 'plugin2'])

        # The order matters...
        config = FakeConfig("plugin1", {'a': 'second'})
        plugins = list(Plugins.load_plugins(["plugin2", "plugin1"], config))

        self.assertEqual(len(plugins), 2)
        self.assertEqual(plugins[0].options, {})
        self.assertEqual(plugins[1].this_is, "me")
        self.assertEqual(plugins[1].options, {'a': 'second'})
开发者ID:phenoxim,项目名称:coveragepy,代码行数:35,代码来源:test_plugins.py

示例2: test_implicit_boolean

# 需要导入模块: from coverage.control import Plugins [as 别名]
# 或者: from coverage.control.Plugins import load_plugins [as 别名]
    def test_implicit_boolean(self):
        self.make_file("plugin1.py", """\
            from coverage import CoveragePlugin

            class Plugin(CoveragePlugin):
                pass
            """)

        config = FakeConfig("plugin1", {})
        plugins = Plugins.load_plugins([], config)
        self.assertFalse(plugins)

        plugins = Plugins.load_plugins(["plugin1"], config)
        self.assertTrue(plugins)
开发者ID:phenoxim,项目名称:coveragepy,代码行数:16,代码来源:test_plugins.py

示例3: test_implicit_boolean

# 需要导入模块: from coverage.control import Plugins [as 别名]
# 或者: from coverage.control.Plugins import load_plugins [as 别名]
    def test_implicit_boolean(self):
        self.make_file("plugin1.py", """\
            from coverage import CoveragePlugin

            class Plugin(CoveragePlugin):
                pass

            def coverage_init(reg, options):
                reg.add_file_tracer(Plugin())
            """)

        config = FakeConfig("plugin1", {})
        plugins = Plugins.load_plugins([], config)
        self.assertFalse(plugins)

        plugins = Plugins.load_plugins(["plugin1"], config)
        self.assertTrue(plugins)
开发者ID:hugovk,项目名称:coveragepy,代码行数:19,代码来源:test_plugins.py

示例4: test_plugin_must_define_coverage_init

# 需要导入模块: from coverage.control import Plugins [as 别名]
# 或者: from coverage.control.Plugins import load_plugins [as 别名]
 def test_plugin_must_define_coverage_init(self):
     self.make_file("no_plugin.py", """\
         from coverage import CoveragePlugin
         Nothing = 0
         """)
     msg_pat = "Plugin module 'no_plugin' didn't define a coverage_init function"
     with self.assertRaisesRegex(CoverageException, msg_pat):
         list(Plugins.load_plugins(["no_plugin"], None))
开发者ID:hugovk,项目名称:coveragepy,代码行数:10,代码来源:test_plugins.py

示例5: test_importing_and_configuring_more_than_one

# 需要导入模块: from coverage.control import Plugins [as 别名]
# 或者: from coverage.control.Plugins import load_plugins [as 别名]
    def test_importing_and_configuring_more_than_one(self):
        self.make_file(
            "plugin1.py",
            """\
            from coverage import CoveragePlugin

            class Plugin(CoveragePlugin):
                def __init__(self, options):
                    self.options = options
                    self.this_is = "me"

            def coverage_init(reg, options):
                reg.add_file_tracer(Plugin(options))
            """,
        )
        self.make_file(
            "plugin2.py",
            """\
            from coverage import CoveragePlugin

            class Plugin(CoveragePlugin):
                def __init__(self, options):
                    self.options = options

            def coverage_init(reg, options):
                reg.add_file_tracer(Plugin(options))
            """,
        )

        config = FakeConfig("plugin1", {"a": "hello"})
        plugins = list(Plugins.load_plugins(["plugin1", "plugin2"], config))

        self.assertEqual(len(plugins), 2)
        self.assertEqual(plugins[0].this_is, "me")
        self.assertEqual(plugins[0].options, {"a": "hello"})
        self.assertEqual(plugins[1].options, {})
        self.assertEqual(config.asked_for, ["plugin1", "plugin2"])

        # The order matters...
        config = FakeConfig("plugin1", {"a": "second"})
        plugins = list(Plugins.load_plugins(["plugin2", "plugin1"], config))

        self.assertEqual(len(plugins), 2)
        self.assertEqual(plugins[0].options, {})
        self.assertEqual(plugins[1].this_is, "me")
        self.assertEqual(plugins[1].options, {"a": "second"})
开发者ID:silviot,项目名称:coveragepy,代码行数:48,代码来源:test_plugins.py

示例6: test_importing_and_configuring

# 需要导入模块: from coverage.control import Plugins [as 别名]
# 或者: from coverage.control.Plugins import load_plugins [as 别名]
    def test_importing_and_configuring(self):
        self.make_file("plugin1.py", """\
            from coverage import CoveragePlugin

            class Plugin(CoveragePlugin):
                def __init__(self, options):
                    super(Plugin, self).__init__(options)
                    self.this_is = "me"
            """)

        config = FakeConfig("plugin1", {'a': 'hello'})
        plugins = list(Plugins.load_plugins(["plugin1"], config))

        self.assertEqual(len(plugins), 1)
        self.assertEqual(plugins[0].this_is, "me")
        self.assertEqual(plugins[0].options, {'a': 'hello'})
        self.assertEqual(config.asked_for, ['plugin1'])
开发者ID:phenoxim,项目名称:coveragepy,代码行数:19,代码来源:test_plugins.py

示例7: test_cant_import

# 需要导入模块: from coverage.control import Plugins [as 别名]
# 或者: from coverage.control.Plugins import load_plugins [as 别名]
 def test_cant_import(self):
     with self.assertRaisesRegex(ImportError, "No module named '?plugin_not_there'?"):
         _ = Plugins.load_plugins(["plugin_not_there"], None)
开发者ID:hugovk,项目名称:coveragepy,代码行数:5,代码来源:test_plugins.py

示例8: test_cant_import

# 需要导入模块: from coverage.control import Plugins [as 别名]
# 或者: from coverage.control.Plugins import load_plugins [as 别名]
 def test_cant_import(self):
     with self.assertRaises(ImportError):
         _ = Plugins.load_plugins(["plugin_not_there"], None)
开发者ID:TheRockStarDBA,项目名称:coveragepy,代码行数:5,代码来源:test_plugins.py


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