31
31
import bzrlib.plugins
32
32
import bzrlib.commands
34
from bzrlib.symbol_versioning import zero_ninetyone
34
from bzrlib.symbol_versioning import one_three
35
35
from bzrlib.tests import TestCase, TestCaseInTempDir
36
36
from bzrlib.osutils import pathjoin, abspath, normpath
217
class TestAllPlugins(TestCaseInTempDir):
219
def test_plugin_appears_in_all_plugins(self):
220
# This test tests a new plugin appears in bzrlib.plugin.all_plugins().
221
# check the plugin is not loaded already
222
self.failIf(getattr(bzrlib.plugins, 'plugin', None))
223
# write a plugin that _cannot_ fail to load.
224
file('plugin.py', 'w').write("\n")
226
bzrlib.plugin.load_from_path(['.'])
227
all_plugins = self.applyDeprecated(zero_ninetyone,
228
bzrlib.plugin.all_plugins)
229
self.failUnless('plugin' in all_plugins)
230
self.failUnless(getattr(bzrlib.plugins, 'plugin', None))
231
self.assertEqual(all_plugins['plugin'], bzrlib.plugins.plugin)
233
# remove the plugin 'plugin'
234
if 'bzrlib.plugins.plugin' in sys.modules:
235
del sys.modules['bzrlib.plugins.plugin']
236
if getattr(bzrlib.plugins, 'plugin', None):
237
del bzrlib.plugins.plugin
238
self.failIf(getattr(bzrlib.plugins, 'plugin', None))
241
217
class TestPlugins(TestCaseInTempDir):
243
219
def setup_plugin(self, source=""):
409
385
# this is normally done by load_plugins -> set_plugins_path
410
386
bzrlib.plugins.__path__ = [zip_name]
411
bzrlib.plugin.load_from_zip(zip_name)
387
self.applyDeprecated(one_three,
388
bzrlib.plugin.load_from_zip, zip_name)
412
389
self.assertTrue(plugin_name in dir(bzrlib.plugins),
413
390
'Plugin is not loaded')