/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_plugins.py

  • Committer: Martin Pool
  • Date: 2007-08-20 05:53:39 UTC
  • mfrom: (2727 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2730.
  • Revision ID: mbp@sourcefrog.net-20070820055339-uzei7f7i7jo6tugg
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
148
148
    def split_help_commands(self):
149
149
        help = {}
150
150
        current = None
151
 
        for line in self.capture('help commands').splitlines():
 
151
        for line in self.run_bzr('help commands')[0].splitlines():
152
152
            if not line.startswith(' '):
153
153
                current = line.split()[0]
154
154
            help[current] = help.get(current, '') + line
167
167
                # some commands have no help
168
168
                pass
169
169
            else:
170
 
                self.assertNotContainsRe(help, 'From plugin "[^"]*"')
 
170
                self.assertNotContainsRe(help, 'plugin "[^"]*"')
171
171
 
172
172
            if cmd_name in help_commands.keys():
173
173
                # some commands are hidden
174
174
                help = help_commands[cmd_name]
175
 
                self.assertNotContainsRe(help, 'From plugin "[^"]*"')
 
175
                self.assertNotContainsRe(help, 'plugin "[^"]*"')
176
176
 
177
177
    def test_plugin_help_shows_plugin(self):
178
178
        # Create a test plugin
185
185
            # Check its help
186
186
            bzrlib.plugin.load_from_path(['plugin_test'])
187
187
            bzrlib.commands.register_command( bzrlib.plugins.myplug.cmd_myplug)
188
 
            help = self.capture('help myplug')
189
 
            self.assertContainsRe(help, 'From plugin "myplug"')
 
188
            help = self.run_bzr('help myplug')[0]
 
189
            self.assertContainsRe(help, 'plugin "myplug"')
190
190
            help = self.split_help_commands()['myplug']
191
191
            self.assertContainsRe(help, '\[myplug\]')
192
192
        finally:
208
208
    def check_plugin_load(self, zip_name, plugin_name):
209
209
        self.assertFalse(plugin_name in dir(bzrlib.plugins),
210
210
                         'Plugin already loaded')
 
211
        old_path = bzrlib.plugins.__path__
211
212
        try:
 
213
            # this is normally done by load_plugins -> set_plugins_path
 
214
            bzrlib.plugins.__path__ = [zip_name]
212
215
            bzrlib.plugin.load_from_zip(zip_name)
213
216
            self.assertTrue(plugin_name in dir(bzrlib.plugins),
214
217
                            'Plugin is not loaded')
216
219
            # unregister plugin
217
220
            if getattr(bzrlib.plugins, plugin_name, None):
218
221
                delattr(bzrlib.plugins, plugin_name)
 
222
                del sys.modules['bzrlib.plugins.' + plugin_name]
 
223
            bzrlib.plugins.__path__ = old_path
219
224
 
220
225
    def test_load_module(self):
221
226
        self.make_zipped_plugin('./test.zip', 'ziplug.py')