selftest problem: No module named launchpad

Robert Collins robertc at robertcollins.net
Thu Apr 26 05:39:55 BST 2007


On Wed, 2007-04-25 at 16:34 +1000, Martin Pool wrote:
> On 4/25/07, Marius Kruger <amanic at gmail.com> wrote:
> > (tomorrow came and tomorrow gone)
> > should I submit a bug so we don't forget about it?
> > But since it was introduced after feature freeze, maybe it should be fixed
> > before 0.16..
> 
> I think you're right, how about this fix?

What about:
=== modified file 'bzrlib/tests/test_plugins.py'
--- bzrlib/tests/test_plugins.py	2007-04-20 05:44:37 +0000
+++ bzrlib/tests/test_plugins.py	2007-04-26 04:39:37 +0000
@@ -253,14 +253,16 @@
     def test_get_topics_launchpad(self):
         """Searching for 'launchpad' returns the launchpad plugin
docstring."""
         index = plugin.PluginsHelpIndex()
-        # if bzr was run with '--no-plugins' we need to manually load
the
-        # reference plugin. Its shipped with bzr, and loading at this
point
-        # won't add additional tests to run.
-        import bzrlib.plugins.launchpad
-        topics = index.get_topics('launchpad')
-        self.assertEqual(1, len(topics))
-        self.assertIsInstance(topics[0], plugin.ModuleHelpTopic)
-        self.assertEqual(bzrlib.plugins.launchpad, topics[0].module)
+
self.assertFalse(sys.modules.has_key('bzrlib.plugins.get_topics'))
+        demo_module = FakeModule('', 'bzrlib.plugins.get_topics')
+        sys.modules['bzrlib.plugins.get_topics'] = demo_module
+        try:
+            topics = index.get_topics('get_topics')
+            self.assertEqual(1, len(topics))
+            self.assertIsInstance(topics[0], plugin.ModuleHelpTopic)
+            self.assertEqual(demo_module, topics[0].module)
+        finally:
+            del sys.modules['bzrlib.plugins.get_topics']
 
     def test_get_topics_no_topic(self):
         """Searching for something that is not a plugin returns []."""
@@ -277,14 +279,16 @@
     def test_get_topic_with_prefix(self):
         """Searching for plugins/launchpad returns launchpad module
help."""
         index = plugin.PluginsHelpIndex()
-        # if bzr was run with '--no-plugins' we need to manually load
the
-        # reference plugin. Its shipped with bzr, and loading at this
point
-        # won't add additional tests to run.
-        import bzrlib.plugins.launchpad
-        topics = index.get_topics('plugins/launchpad')
-        self.assertEqual(1, len(topics))
-        self.assertIsInstance(topics[0], plugin.ModuleHelpTopic)
-        self.assertEqual(bzrlib.plugins.launchpad, topics[0].module)
+
self.assertFalse(sys.modules.has_key('bzrlib.plugins.get_topics'))
+        demo_module = FakeModule('', 'bzrlib.plugins.get_topics')
+        sys.modules['bzrlib.plugins.get_topics'] = demo_module
+        try:
+            topics = index.get_topics('plugins/get_topics')
+            self.assertEqual(1, len(topics))
+            self.assertIsInstance(topics[0], plugin.ModuleHelpTopic)
+            self.assertEqual(demo_module, topics[0].module)
+        finally:
+            del sys.modules['bzrlib.plugins.get_topics']
 
 
 class FakeModule(object):

-Rob
-- 
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20070426/917b49b6/attachment.pgp 


More information about the bazaar mailing list