You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.0 KiB
47 lines
1.0 KiB
import pytest
|
|
from disco.bot.plugin import Plugin, register_plugin_base_class, find_loadable_plugins
|
|
|
|
|
|
def _test_module(**kwargs):
|
|
class MyTestModule(object):
|
|
pass
|
|
|
|
m = MyTestModule()
|
|
|
|
for k, v in kwargs.items():
|
|
setattr(m, k, v)
|
|
|
|
return m
|
|
|
|
|
|
def test_shallow_attribute_deprecated():
|
|
class MyPluginBaseClass(Plugin):
|
|
_shallow = True
|
|
|
|
class RegularPlugin(Plugin):
|
|
pass
|
|
|
|
with pytest.warns(DeprecationWarning):
|
|
plugins = list(find_loadable_plugins(_test_module(
|
|
MyPluginBaseClass=MyPluginBaseClass,
|
|
RegularPlugin=RegularPlugin,
|
|
)))
|
|
|
|
assert plugins == [RegularPlugin]
|
|
|
|
|
|
def test_register_plugin_base_class():
|
|
class MyPluginBaseClass(Plugin):
|
|
pass
|
|
|
|
class RegularPlugin(MyPluginBaseClass):
|
|
pass
|
|
|
|
register_plugin_base_class(MyPluginBaseClass)
|
|
|
|
plugins = list(find_loadable_plugins(_test_module(
|
|
MyPluginBaseClass=MyPluginBaseClass,
|
|
RegularPlugin=RegularPlugin,
|
|
)))
|
|
|
|
assert plugins == [RegularPlugin]
|
|
|