~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_plugins.py

  • Committer: v.ladeuil+lp at free
  • Date: 2007-05-18 18:20:31 UTC
  • mto: (2485.8.44 bzr.connection.sharing)
  • mto: This revision was merged to the branch mainline in revision 2646.
  • Revision ID: v.ladeuil+lp@free.fr-20070518182031-gbg2cgidv5l20x9p
Takes Robert comments into account.

* bzrlib/transport/ftp.py:
(FtpTransport.__init__): Write a better explanation.

* bzrlib/tests/test_init.py:
(InstrumentedTransport): Just make hooks a class attribute.
(InstrumentedTransport._get_FTP): Run hook directly in the for
loop.
(TransportHooks.run_hook, TransportHooks.uninstall_hook): Not
needed. The hooks should be cleaned up by the test itself.
(TestInit.setUp.cleanup): Resset to default hooks.

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.run_bzr('help commands')[0].splitlines():
 
151
        for line in self.capture('help commands').splitlines():
152
152
            if not line.startswith(' '):
153
153
                current = line.split()[0]
154
154
            help[current] = help.get(current, '') + line
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.run_bzr('help myplug')[0]
 
188
            help = self.capture('help myplug')
189
189
            self.assertContainsRe(help, 'From plugin "myplug"')
190
190
            help = self.split_help_commands()['myplug']
191
191
            self.assertContainsRe(help, '\[myplug\]')
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__
212
211
        try:
213
 
            # this is normally done by load_plugins -> set_plugins_path
214
 
            bzrlib.plugins.__path__ = [zip_name]
215
212
            bzrlib.plugin.load_from_zip(zip_name)
216
213
            self.assertTrue(plugin_name in dir(bzrlib.plugins),
217
214
                            'Plugin is not loaded')
219
216
            # unregister plugin
220
217
            if getattr(bzrlib.plugins, plugin_name, None):
221
218
                delattr(bzrlib.plugins, plugin_name)
222
 
                del sys.modules['bzrlib.plugins.' + plugin_name]
223
 
            bzrlib.plugins.__path__ = old_path
224
219
 
225
220
    def test_load_module(self):
226
221
        self.make_zipped_plugin('./test.zip', 'ziplug.py')