From bb8da0bb60e0605efaf7e5093a6a7afa9898df0e Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Tue, 1 Jul 2014 00:58:17 +0200 Subject: Added an advanced example of discovery --- tests/plugins/advanced.py | 11 +++++++++++ tests/test_advanced.py | 8 ++++++++ 2 files changed, 19 insertions(+) create mode 100644 tests/plugins/advanced.py create mode 100644 tests/test_advanced.py (limited to 'tests') 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' -- cgit v1.2.1