137
140
if getattr(bzrlib.plugins, 'plugin', None):
138
141
del bzrlib.plugins.plugin
139
142
self.failIf(getattr(bzrlib.plugins, 'plugin', None))
145
class TestPluginHelp(TestCaseInTempDir):
147
def split_help_commands(self):
150
for line in self.capture('help commands').splitlines():
151
if line.startswith('bzr '):
152
current = line.split()[1]
153
help[current] = help.get(current, '') + line
157
def test_plugin_help_builtins_unaffected(self):
158
# Check we don't get false positives
159
help_commands = self.split_help_commands()
160
for cmd_name in bzrlib.commands.builtin_command_names():
161
if cmd_name in bzrlib.commands.plugin_command_names():
165
bzrlib.help.help_on_command(cmd_name, help)
166
except NotImplementedError:
167
# some commands have no help
171
self.assertNotContainsRe(help.read(), 'From plugin "[^"]*"')
173
if help in help_commands.keys():
174
# some commands are hidden
175
help = help_commands[cmd_name]
176
self.assertNotContainsRe(help, 'From plugin "[^"]*"')
178
def test_plugin_help_shows_plugin(self):
179
# Create a test plugin
180
os.mkdir('plugin_test')
181
f = open(pathjoin('plugin_test', 'myplug.py'), 'w')
187
bzrlib.plugin.load_from_dirs(['plugin_test'])
188
bzrlib.commands.register_command( bzrlib.plugins.myplug.cmd_myplug)
189
help = self.capture('help myplug')
190
self.assertContainsRe(help, 'From plugin "myplug"')
191
help = self.split_help_commands()['myplug']
192
self.assertContainsRe(help, 'From plugin "myplug"')
194
# remove the plugin 'plugin'
195
if getattr(bzrlib.plugins, 'plugin', None):
196
del bzrlib.plugins.plugin