def __init__(self): self.search_path = [ help_topics.HelpTopicIndex(), _mod_commands.HelpCommandIndex(), plugin.PluginsHelpIndex(), help_topics.ConfigOptionHelpIndex(), ]
def test_get_plugin_topic_with_prefix(self): """Searching for plugins/demo_module returns help.""" index = plugin.PluginsHelpIndex() self.assertFalse(sys.modules.has_key('bzrlib.plugins.demo_module')) demo_module = FakeModule('', 'bzrlib.plugins.demo_module') sys.modules['bzrlib.plugins.demo_module'] = demo_module try: topics = index.get_topics('plugins/demo_module') self.assertEqual(1, len(topics)) self.assertIsInstance(topics[0], plugin.ModuleHelpTopic) self.assertEqual(demo_module, topics[0].module) finally: del sys.modules['bzrlib.plugins.demo_module']
def test_get_topics_for_plugin(self): """Searching for plugin name gets its docstring.""" index = plugin.PluginsHelpIndex() # make a new plugin here for this test, even if we're run with # --no-plugins self.assertFalse(sys.modules.has_key('bzrlib.plugins.demo_module')) demo_module = FakeModule('', 'bzrlib.plugins.demo_module') sys.modules['bzrlib.plugins.demo_module'] = demo_module try: topics = index.get_topics('demo_module') self.assertEqual(1, len(topics)) self.assertIsInstance(topics[0], plugin.ModuleHelpTopic) self.assertEqual(demo_module, topics[0].module) finally: del sys.modules['bzrlib.plugins.demo_module']
def test_prefix(self): """PluginsHelpIndex has a prefix of 'plugins/'.""" index = plugin.PluginsHelpIndex() self.assertEqual('plugins/', index.prefix)
def test_get_topics_no_topic(self): """Searching for something that is not a plugin returns [].""" # test this by using a name that cannot be a plugin - its not # a valid python identifier. index = plugin.PluginsHelpIndex() self.assertEqual([], index.get_topics('nothing by this name'))
def test_get_topics_None(self): """Searching for None returns an empty list.""" index = plugin.PluginsHelpIndex() self.assertEqual([], index.get_topics(None))
def test_default_constructable(self): index = plugin.PluginsHelpIndex()