/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: Vincent Ladeuil
  • Date: 2010-04-02 09:26:40 UTC
  • mto: (5133.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5134.
  • Revision ID: v.ladeuil+lp@free.fr-20100402092640-nn2mtg4g249ji0e6
Fix bug #552922 by controlling which files can be used to load a plugin.

* bzrlib/tests/test_plugins.py:
(TestLoadPluginAt.test_loading_from___init__): Add one more test
when loading from a file.

* bzrlib/plugin.py:
(_PluginImporter.load_module): Don't use _find_module as its
contract is also to find the plugin name. We *know* the plugin
name here.

Show diffs side-by-side

added added

removed removed

Lines of Context:
814
814
        # avoid depending on the precise naming.
815
815
        self.create_plugin_package('test_foo', dir='standard/test_foo')
816
816
 
817
 
    def assertTestFooLoadedFrom(self, dir):
 
817
    def assertTestFooLoadedFrom(self, path):
818
818
        self.assertPluginKnown('test_foo')
819
819
        self.assertEqual('This is the doc for test_foo',
820
820
                         bzrlib.plugins.test_foo.__doc__)
821
 
        self.assertEqual(dir, bzrlib.plugins.test_foo.dir_source)
 
821
        self.assertEqual(path, bzrlib.plugins.test_foo.dir_source)
822
822
 
823
823
    def test_regular_load(self):
824
824
        plugin.load_plugins(['standard'])
879
879
        osutils.set_or_unset_env('BZR_PLUGINS_AT', 'test_foo@non-standard-dir')
880
880
        plugin.load_plugins(['standard'])
881
881
        self.assertPluginUnknown('test_foo')
 
882
 
 
883
    def test_loading_from_specific_file(self):
 
884
        plugin_dir = 'non-standard-dir'
 
885
        plugin_file_name = 'iamtestfoo.py'
 
886
        plugin_path = osutils.pathjoin(plugin_dir, plugin_file_name)
 
887
        source = '''\
 
888
"""This is the doc for %s"""
 
889
dir_source = '%s'
 
890
''' % ('test_foo', plugin_path)
 
891
        self.create_plugin('test_foo', source=source,
 
892
                           dir=plugin_dir, file_name=plugin_file_name)
 
893
        osutils.set_or_unset_env('BZR_PLUGINS_AT', 'test_foo@%s' % plugin_path)
 
894
        plugin.load_plugins(['standard'])
 
895
        self.assertTestFooLoadedFrom(plugin_path)