diff options
author | Armin Ronacher <armin.ronacher@active-4.com> | 2014-07-01 00:58:17 +0200 |
---|---|---|
committer | Armin Ronacher <armin.ronacher@active-4.com> | 2014-07-01 00:58:17 +0200 |
commit | bb8da0bb60e0605efaf7e5093a6a7afa9898df0e (patch) | |
tree | 8e16e51e53e6c5d8e20b3d4b0b5242f35aa37ee7 /tests | |
parent | 51ad212d197146ce90f7a79c2eef16f85cdb2a47 (diff) | |
download | pluginbase-bb8da0bb60e0605efaf7e5093a6a7afa9898df0e.tar.gz |
Added an advanced example of discovery
Diffstat (limited to 'tests')
-rw-r--r-- | tests/plugins/advanced.py | 11 | ||||
-rw-r--r-- | tests/test_advanced.py | 8 |
2 files changed, 19 insertions, 0 deletions
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' |