~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: 2010-05-20 09:27:48 UTC
  • mfrom: (5241.2.2 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20100520092748-oa7knubtqio8l2rc
(lifeless) Merge 2.1 into trunk with a number of fixes including pyrex 0.9.9
 support. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
473
473
        f.write("""\
474
474
from bzrlib import commands
475
475
class cmd_myplug(commands.Command):
476
 
    '''Just a simple test plugin.'''
 
476
    __doc__ = '''Just a simple test plugin.'''
477
477
    aliases = ['mplg']
478
478
    def run(self):
479
479
        print 'Hello from my plugin'
780
780
        self.overrideAttr(plugin, '_loaded', False)
781
781
        plugin.load_plugins(['.'])
782
782
        self.assertPluginKnown('test_foo')
783
 
        self.assertEqual("This is the doc for test_foo",
784
 
                         bzrlib.plugins.test_foo.__doc__)
 
783
        self.assertDocstring("This is the doc for test_foo",
 
784
                             bzrlib.plugins.test_foo)
785
785
 
786
786
    def test_not_loaded(self):
787
787
        self.warnings = []
816
816
 
817
817
    def assertTestFooLoadedFrom(self, path):
818
818
        self.assertPluginKnown('test_foo')
819
 
        self.assertEqual('This is the doc for test_foo',
820
 
                         bzrlib.plugins.test_foo.__doc__)
 
819
        self.assertDocstring('This is the doc for test_foo',
 
820
                             bzrlib.plugins.test_foo)
821
821
        self.assertEqual(path, bzrlib.plugins.test_foo.dir_source)
822
822
 
823
823
    def test_regular_load(self):
842
842
        osutils.set_or_unset_env('BZR_PLUGINS_AT', 'test_foo@non-standard-dir')
843
843
        plugin.load_plugins(['standard'])
844
844
        self.assertTestFooLoadedFrom('non-standard-dir')
845
 
        self.assertEqual('non-standard-dir/__init__.py',
846
 
                         bzrlib.plugins.test_foo.__file__)
 
845
        self.assertIsSameRealPath('non-standard-dir/__init__.py',
 
846
                                  bzrlib.plugins.test_foo.__file__)
847
847
 
848
848
        # Try importing again now that the source has been compiled
849
849
        self._unregister_plugin('test_foo')
854
854
            suffix = 'pyc'
855
855
        else:
856
856
            suffix = 'pyo'
857
 
        self.assertEqual('non-standard-dir/__init__.%s' % suffix,
858
 
                         bzrlib.plugins.test_foo.__file__)
 
857
        self.assertIsSameRealPath('non-standard-dir/__init__.%s' % suffix,
 
858
                                  bzrlib.plugins.test_foo.__file__)
859
859
 
860
860
    def test_submodule_loading(self):
861
861
        # We create an additional directory under the one for test_foo
866
866
        self.assertEqual('bzrlib.plugins.test_foo',
867
867
                         bzrlib.plugins.test_foo.__package__)
868
868
        import bzrlib.plugins.test_foo.test_bar
869
 
        self.assertEqual('non-standard-dir/test_bar/__init__.py',
870
 
                         bzrlib.plugins.test_foo.test_bar.__file__)
 
869
        self.assertIsSameRealPath('non-standard-dir/test_bar/__init__.py',
 
870
                                  bzrlib.plugins.test_foo.test_bar.__file__)
871
871
 
872
872
    def test_loading_from___init__only(self):
873
873
        # We rename the existing __init__.py file to ensure that we don't load