本文整理汇总了Python中coverage.control.Plugins类的典型用法代码示例。如果您正苦于以下问题:Python Plugins类的具体用法?Python Plugins怎么用?Python Plugins使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Plugins类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_importing_and_configuring_more_than_one
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'})
示例2: test_implicit_boolean
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)
示例3: test_implicit_boolean
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)
示例4: test_plugin_must_define_coverage_init
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))
示例5: test_importing_and_configuring_more_than_one
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"})
示例6: test_importing_and_configuring
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'])
示例7: test_cant_import
def test_cant_import(self):
with self.assertRaisesRegex(ImportError, "No module named '?plugin_not_there'?"):
_ = Plugins.load_plugins(["plugin_not_there"], None)
示例8: test_cant_import
def test_cant_import(self):
with self.assertRaises(ImportError):
_ = Plugins.load_plugins(["plugin_not_there"], None)