示例#1
0
def test_info_with_function_with_wrong_label(plugin_package):
    """Test that info() is strict about matching label to function"""
    with pytest.raises(pyplugs.UnknownPluginFunctionError):
        pyplugs.info(plugin_package,
                     "plugin_labels",
                     func="plugin_one",
                     label="label")
示例#2
0
def test_plugin_not_exists(plugin_package, plugin_name):
    """Test that a non-existing plugin raises UnknownPluginError

    Tests both for an existing module (no_plugins) and a non-existent module
    (non_existent).
    """
    with pytest.raises(pyplugs.UnknownPluginError):
        pyplugs.info(plugin_package, plugin_name)
示例#3
0
def test_info_factory(plugin_package):
    """Test that the info factory can retrieve info in package"""
    plugin_name = "plugin_parts"
    info = pyplugs.info_factory(plugin_package)
    factory_info = info(plugin_name)
    pyplugs_info = pyplugs.info(plugin_package, plugin=plugin_name)
    assert factory_info == pyplugs_info
示例#4
0
def test_plugin_exists(plugin_package):
    """Test that an existing plugin returns its own plugin name"""
    plugin_name = pyplugs.names(plugin_package)[0]
    assert pyplugs.info(plugin_package, plugin_name).plugin_name == plugin_name
示例#5
0
def test_long_doc(plugin_package):
    """Test that we can retrieve the long docstring from a plugin"""
    plugin_name = "plugin_plain"
    doc = pyplugs.info(plugin_package, plugin_name).doc
    assert doc == "This is the plain docstring."
示例#6
0
def test_short_doc(plugin_package):
    """Test that we can retrieve the short docstring from a plugin"""
    plugin_name = "plugin_plain"
    doc = pyplugs.info(plugin_package, plugin_name).description
    assert doc == "A plain plugin"
示例#7
0
def test_info_with_no_plugins(plugin_package):
    """Test that info() raises a proper error when there are no plugins available"""
    with pytest.raises(pyplugs.UnknownPluginError):
        pyplugs.info(plugin_package, "no_plugins")
示例#8
0
def test_info_with_wrong_label(plugin_package):
    """Test that info() raises error when label is wrong"""
    with pytest.raises(pyplugs.UnknownPluginFunctionError):
        pyplugs.info(plugin_package, "plugin_labels", label="wrong_label")
示例#9
0
def test_info_with_label(plugin_package):
    """Test that the info gives information about a labeled plugin"""
    plugin_info = pyplugs.info(plugin_package, "plugin_labels", label="label")
    assert isinstance(plugin_info, pyplugs.PluginInfo)
    assert plugin_info.func_name == "plugin_first_label"
示例#10
0
def test_info(plugin_package):
    """Test that the info gives information about a plugin"""
    plugin_info = pyplugs.info(plugin_package, "plugin_plain")
    assert isinstance(plugin_info, pyplugs.PluginInfo)
    assert plugin_info.func() == "plain"