selftest problem: No module named launchpad

Marius Kruger amanic at gmail.com
Thu Apr 26 05:48:20 BST 2007


this seems more correct.
+1 from me if it works

On 4/26/07, Robert Collins <robertc at robertcollins.net> wrote:
>
> ...
> 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>.
>
>


-- 
I don't trust a Revision Control System with less than 6400 unit tests.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.ubuntu.com/archives/bazaar/attachments/20070426/d67ba733/attachment.htm 


More information about the bazaar mailing list