~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_plugins.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-12-21 04:13:14 UTC
  • mfrom: (2197.2.2 diff-refactoring)
  • Revision ID: pqm@pqm.ubuntu.com-20061221041314-2991e63a023efcf1
(mbp) initial cleanups of cmd_diff (r=john)

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
import os
24
24
from StringIO import StringIO
25
 
import zipfile
26
25
 
27
26
import bzrlib.plugin
28
27
import bzrlib.plugins
191
190
            help = self.split_help_commands()['myplug']
192
191
            self.assertContainsRe(help, '\[myplug\]')
193
192
        finally:
194
 
            # unregister command
195
 
            if bzrlib.commands.plugin_cmds.get('myplug', None):
196
 
                del bzrlib.commands.plugin_cmds['myplug']
197
 
            # remove the plugin 'myplug'
198
 
            if getattr(bzrlib.plugins, 'myplug', None):
199
 
                delattr(bzrlib.plugins, 'myplug')
200
 
 
201
 
 
202
 
class TestPluginFromZip(TestCaseInTempDir):
203
 
 
204
 
    def make_zipped_plugin(self, zip_name, filename):
205
 
        z = zipfile.ZipFile(zip_name, 'w')
206
 
        z.writestr(filename, PLUGIN_TEXT)
207
 
        z.close()
208
 
 
209
 
    def check_plugin_load(self, zip_name, plugin_name):
210
 
        self.assertFalse(plugin_name in dir(bzrlib.plugins),
211
 
                         'Plugin already loaded')
212
 
        try:
213
 
            bzrlib.plugin.load_from_zips([zip_name])
214
 
            self.assertTrue(plugin_name in dir(bzrlib.plugins),
215
 
                            'Plugin is not loaded')
216
 
        finally:
217
 
            # unregister plugin
218
 
            if getattr(bzrlib.plugins, plugin_name, None):
219
 
                delattr(bzrlib.plugins, plugin_name)
220
 
 
221
 
    def test_load_module(self):
222
 
        self.make_zipped_plugin('./test.zip', 'ziplug.py')
223
 
        self.check_plugin_load('./test.zip', 'ziplug')
224
 
 
225
 
    def test_load_package(self):
226
 
        self.make_zipped_plugin('./test.zip', 'ziplug/__init__.py')
227
 
        self.check_plugin_load('./test.zip', 'ziplug')
 
193
            # remove the plugin 'plugin'
 
194
            if getattr(bzrlib.plugins, 'plugin', None):
 
195
                del bzrlib.plugins.plugin