~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: 2009-01-08 22:52:56 UTC
  • mfrom: (3908.1.5 no-plugins-testsuite)
  • Revision ID: pqm@pqm.ubuntu.com-20090108225256-26dj4mre937k2u6q
Fix test_plugins so that it doesn't cause real plugins to be loaded.
        (Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
404
404
    def split_help_commands(self):
405
405
        help = {}
406
406
        current = None
407
 
        for line in self.run_bzr('help commands')[0].splitlines():
 
407
        out, err = self.run_bzr('--no-plugins help commands')
 
408
        for line in out.splitlines():
408
409
            if not line.startswith(' '):
409
410
                current = line.split()[0]
410
411
            help[current] = help.get(current, '') + line
632
633
 
633
634
 
634
635
def clear_plugins(test_case):
 
636
    # Save the attributes that we're about to monkey-patch.
635
637
    old_plugins_path = bzrlib.plugins.__path__
 
638
    old_loaded = plugin._loaded
 
639
    old_load_from_path = plugin.load_from_path
 
640
    # Change bzrlib.plugin to think no plugins have been loaded yet.
636
641
    bzrlib.plugins.__path__ = []
637
642
    plugin._loaded = False
 
643
    # Monkey-patch load_from_path to stop it from actually loading anything.
 
644
    def load_from_path(dirs):
 
645
        pass
 
646
    plugin.load_from_path = load_from_path
638
647
    def restore_plugins():
639
648
        bzrlib.plugins.__path__ = old_plugins_path
640
 
        plugin._loaded = False
 
649
        plugin._loaded = old_loaded
 
650
        plugin.load_from_path = old_load_from_path
641
651
    test_case.addCleanup(restore_plugins)
642
652
 
643
653