~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_plugins.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-04-26 06:21:34 UTC
  • mfrom: (2457.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20070426062134-r5pvo74u33vke1km
(robertc) Fix bzr --no-plugins selftest which was broken by the help indices patch. (Robert Collins, Martin Pool)

Show diffs side-by-side

added added

removed removed

Lines of Context:
253
253
    def test_get_topics_launchpad(self):
254
254
        """Searching for 'launchpad' returns the launchpad plugin docstring."""
255
255
        index = plugin.PluginsHelpIndex()
256
 
        # if bzr was run with '--no-plugins' we need to manually load the
257
 
        # reference plugin. Its shipped with bzr, and loading at this point
258
 
        # won't add additional tests to run.
259
 
        import bzrlib.plugins.launchpad
260
 
        topics = index.get_topics('launchpad')
261
 
        self.assertEqual(1, len(topics))
262
 
        self.assertIsInstance(topics[0], plugin.ModuleHelpTopic)
263
 
        self.assertEqual(bzrlib.plugins.launchpad, topics[0].module)
 
256
        self.assertFalse(sys.modules.has_key('bzrlib.plugins.get_topics'))
 
257
        demo_module = FakeModule('', 'bzrlib.plugins.get_topics')
 
258
        sys.modules['bzrlib.plugins.get_topics'] = demo_module
 
259
        try:
 
260
            topics = index.get_topics('get_topics')
 
261
            self.assertEqual(1, len(topics))
 
262
            self.assertIsInstance(topics[0], plugin.ModuleHelpTopic)
 
263
            self.assertEqual(demo_module, topics[0].module)
 
264
        finally:
 
265
            del sys.modules['bzrlib.plugins.get_topics']
264
266
 
265
267
    def test_get_topics_no_topic(self):
266
268
        """Searching for something that is not a plugin returns []."""
277
279
    def test_get_topic_with_prefix(self):
278
280
        """Searching for plugins/launchpad returns launchpad module help."""
279
281
        index = plugin.PluginsHelpIndex()
280
 
        # if bzr was run with '--no-plugins' we need to manually load the
281
 
        # reference plugin. Its shipped with bzr, and loading at this point
282
 
        # won't add additional tests to run.
283
 
        import bzrlib.plugins.launchpad
284
 
        topics = index.get_topics('plugins/launchpad')
285
 
        self.assertEqual(1, len(topics))
286
 
        self.assertIsInstance(topics[0], plugin.ModuleHelpTopic)
287
 
        self.assertEqual(bzrlib.plugins.launchpad, topics[0].module)
 
282
        self.assertFalse(sys.modules.has_key('bzrlib.plugins.get_topics'))
 
283
        demo_module = FakeModule('', 'bzrlib.plugins.get_topics')
 
284
        sys.modules['bzrlib.plugins.get_topics'] = demo_module
 
285
        try:
 
286
            topics = index.get_topics('plugins/get_topics')
 
287
            self.assertEqual(1, len(topics))
 
288
            self.assertIsInstance(topics[0], plugin.ModuleHelpTopic)
 
289
            self.assertEqual(demo_module, topics[0].module)
 
290
        finally:
 
291
            del sys.modules['bzrlib.plugins.get_topics']
288
292
 
289
293
 
290
294
class FakeModule(object):