Rev 2455: Avoid plugin tests failing when run with --no-plugins in http://sourcefrog.net/bzr/plugin-help

Martin Pool mbp at sourcefrog.net
Wed Apr 25 07:33:42 BST 2007


At http://sourcefrog.net/bzr/plugin-help

------------------------------------------------------------
revno: 2455
revision-id: mbp at sourcefrog.net-20070425063340-68rbj3dtcar1s9y1
parent: pqm at pqm.ubuntu.com-20070425054241-urh0t3nequwc2j6q
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: plugin-help
timestamp: Wed 2007-04-25 16:33:40 +1000
message:
  Avoid plugin tests failing when run with --no-plugins
modified:
  bzrlib/plugin.py               plugin.py-20050622060424-829b654519533d69
  bzrlib/tests/test_plugins.py   plugins.py-20050622075746-32002b55e5e943e9
=== modified file 'bzrlib/plugin.py'
--- a/bzrlib/plugin.py	2007-04-20 05:44:37 +0000
+++ b/bzrlib/plugin.py	2007-04-25 06:33:40 +0000
@@ -48,8 +48,8 @@
 
 from bzrlib.trace import mutter, warning, log_exception_quietly
 
-
 DEFAULT_PLUGIN_PATH = None
+_plugins_disabled = False
 _loaded = False
 
 def get_default_plugin_path():
@@ -76,8 +76,9 @@
     """
     # TODO: jam 20060131 This should probably also disable
     #       load_from_dirs()
-    global _loaded
+    global _loaded, _plugins_disabled
     _loaded = True
+    _plugins_disabled = True
 
 
 def set_plugins_path():

=== modified file 'bzrlib/tests/test_plugins.py'
--- a/bzrlib/tests/test_plugins.py	2007-04-20 05:44:37 +0000
+++ b/bzrlib/tests/test_plugins.py	2007-04-25 06:33:40 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005 Canonical Ltd
+# Copyright (C) 2005, 2007 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@
 import bzrlib.plugins
 import bzrlib.commands
 import bzrlib.help
-from bzrlib.tests import TestCase, TestCaseInTempDir
+from bzrlib.tests import TestCase, TestCaseInTempDir, TestSkipped
 from bzrlib.osutils import pathjoin, abspath
 
 
@@ -242,6 +242,11 @@
 class TestHelpIndex(tests.TestCase):
     """Tests for the PluginsHelpIndex class."""
 
+    def _needs_plugins(self):
+        if plugin._plugins_disabled:
+            raise TestSkipped("tests are run with --no-plugins; "
+                    "can't examine launchpad plugin")
+
     def test_default_constructable(self):
         index = plugin.PluginsHelpIndex()
 
@@ -251,7 +256,12 @@
         self.assertEqual([], index.get_topics(None))
 
     def test_get_topics_launchpad(self):
-        """Searching for 'launchpad' returns the launchpad plugin docstring."""
+        """Searching for 'launchpad' returns the launchpad plugin docstring.
+        
+        We can test against this because it's in the Bazaar source tree,
+        unless the tests were run with plugins disabled.
+        """
+        self._needs_plugins()
         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
@@ -276,6 +286,7 @@
 
     def test_get_topic_with_prefix(self):
         """Searching for plugins/launchpad returns launchpad module help."""
+        self._needs_plugins()
         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




More information about the bazaar-commits mailing list