/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: Andrew Bennetts
  • Date: 2009-01-07 10:04:43 UTC
  • mto: This revision was merged to the branch mainline in revision 3932.
  • Revision ID: andrew.bennetts@canonical.com-20090107100443-xke5btym3ux9pf10
Fix test_plugins to restore the original value of bzrlib.plugin._loaded.

Show diffs side-by-side

added added

removed removed

Lines of Context:
633
633
 
634
634
 
635
635
def clear_plugins(test_case):
 
636
    # Save the attributes that we're about to monkey-patch.
636
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.
637
641
    bzrlib.plugins.__path__ = []
638
642
    plugin._loaded = False
 
643
    # Monkey-patch load_from_path to stop it from actually loading anything.
639
644
    def load_from_path(dirs):
640
645
        pass
641
 
    old_load_from_path = plugin.load_from_path
642
646
    plugin.load_from_path = load_from_path
643
647
    def restore_plugins():
644
648
        bzrlib.plugins.__path__ = old_plugins_path
645
 
        plugin._loaded = False
 
649
        plugin._loaded = old_loaded
646
650
        plugin.load_from_path = old_load_from_path
647
651
    test_case.addCleanup(restore_plugins)
648
652