def test_fetching_plugin_source(source): # Finding the plugin source outside of a plugin and without a with # block of a plugin source returns None. assert get_plugin_source() is None # Inside a source block we can find the source through mere calling. with source: assert get_plugin_source() is source # A module can always find its own source as well (the hello module # calls get_plugin_source() itself). with source: from dummy.plugins import hello assert hello.get_plugin_source() is source # Last but not least the plugin source can be found by module names # (in a plugin source block by the import name and in any case by # the internal name) with source: assert get_plugin_source('dummy.plugins.hello') is source assert get_plugin_source(hello.__name__) is source # As well as by module object. assert get_plugin_source(hello) is source
def get_plugin_source(): from pluginbase import get_plugin_source return get_plugin_source()
def get_app(): rv = get_plugin_source(stacklevel=1) if rv is not None: return rv.app