diff options
| -rw-r--r-- | docs/index.rst | 6 | ||||
| -rw-r--r-- | tests/plugins/advanced.py | 11 | ||||
| -rw-r--r-- | tests/test_advanced.py | 8 |
3 files changed, 22 insertions, 3 deletions
diff --git a/docs/index.rst b/docs/index.rst index c4d4aec..a5c45e7 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -43,10 +43,10 @@ Step 3: from yourapplication.plugins import my_plugin my_plugin.do_something_cool() -Alternatively you can also import plugins programmatically instead of -using the import statement:: + Alternatively you can also import plugins programmatically instead of + using the import statement:: - my_plugin = plugin_source.load_plugin('my_plugin') + my_plugin = plugin_source.load_plugin('my_plugin') Installation ------------ diff --git a/tests/plugins/advanced.py b/tests/plugins/advanced.py new file mode 100644 index 0000000..19eb051 --- /dev/null +++ b/tests/plugins/advanced.py @@ -0,0 +1,11 @@ +from pluginbase import get_plugin_source + + +def get_app(): + rv = get_plugin_source(stacklevel=1) + if rv is not None: + return rv.app + + +def get_app_name(): + return get_app().name diff --git a/tests/test_advanced.py b/tests/test_advanced.py new file mode 100644 index 0000000..d6440a5 --- /dev/null +++ b/tests/test_advanced.py @@ -0,0 +1,8 @@ +def test_custom_state(base): + class App(object): + name = 'foobar' + source = base.make_plugin_source(searchpath=['./plugins']) + source.app = App() + + plg = source.load_plugin('advanced') + assert plg.get_app_name() == 'foobar' |
