79
81
# TODO: Write a test for plugin decoration of commands.
83
class TestOneNamedPluginOnly(TestCaseInTempDir):
87
def test_plugins_with_the_same_name_are_not_loaded(self):
88
# This test tests that having two plugins in different
89
# directories does not result in both being loaded.
90
# get a file name we can use which is also a valid attribute
91
# for accessing in activeattributes. - we cannot give import parameters.
93
self.failIf(tempattribute in self.activeattributes)
94
# set a place for the plugins to record their loading, and at the same
95
# time validate that the location the plugins should record to is
97
bzrlib.tests.test_plugins.TestOneNamedPluginOnly.activeattributes \
99
self.failUnless(tempattribute in self.activeattributes)
100
# create two plugin directories
103
# write a plugin that will record when its loaded in the
104
# tempattribute list.
105
template = ("from bzrlib.tests.test_plugins import TestOneNamedPluginOnly\n"
106
"TestOneNamedPluginOnly.activeattributes[%r].append('%s')\n")
107
print >> file(os.path.join('first', 'plugin.py'), 'w'), template % (tempattribute, 'first')
108
print >> file(os.path.join('second', 'plugin.py'), 'w'), template % (tempattribute, 'second')
110
bzrlib.plugin.load_from_dirs(['first', 'second'])
111
self.assertEqual(['first'], self.activeattributes[tempattribute])
113
# remove the plugin 'plugin'
114
del self.activeattributes[tempattribute]
115
if getattr(bzrlib.plugins, 'plugin', None):
116
del bzrlib.plugins.plugin
117
self.failIf(getattr(bzrlib.plugins, 'plugin', None))