/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 breezy/tests/test_plugins.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-21 18:10:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6623.
  • Revision ID: jelmer@jelmer.uk-20170521181028-zn04pdfw0od9hfj3
Rename brzlib => breezy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""Tests for plugins"""
18
18
 
19
19
# XXX: There are no plugin tests at the moment because the plugin module
20
 
# affects the global state of the process.  See brzlib/plugins.py for more
 
20
# affects the global state of the process.  See breezy/plugins.py for more
21
21
# comments.
22
22
 
23
23
from cStringIO import StringIO
25
25
import os
26
26
import sys
27
27
 
28
 
import brzlib
29
 
from brzlib import (
 
28
import breezy
 
29
from breezy import (
30
30
    errors,
31
31
    osutils,
32
32
    plugin,
73
73
                           file_name='__init__.py')
74
74
 
75
75
    def _unregister_plugin(self, name):
76
 
        """Remove the plugin from sys.modules and the brzlib namespace."""
77
 
        py_name = 'brzlib.plugins.%s' % name
 
76
        """Remove the plugin from sys.modules and the breezy namespace."""
 
77
        py_name = 'breezy.plugins.%s' % name
78
78
        if py_name in sys.modules:
79
79
            del sys.modules[py_name]
80
 
        if getattr(brzlib.plugins, name, None) is not None:
81
 
            delattr(brzlib.plugins, name)
 
80
        if getattr(breezy.plugins, name, None) is not None:
 
81
            delattr(breezy.plugins, name)
82
82
 
83
83
    def _unregister_plugin_submodule(self, plugin_name, submodule_name):
84
 
        """Remove the submodule from sys.modules and the brzlib namespace."""
85
 
        py_name = 'brzlib.plugins.%s.%s' % (plugin_name, submodule_name)
 
84
        """Remove the submodule from sys.modules and the breezy namespace."""
 
85
        py_name = 'breezy.plugins.%s.%s' % (plugin_name, submodule_name)
86
86
        if py_name in sys.modules:
87
87
            del sys.modules[py_name]
88
 
        plugin = getattr(brzlib.plugins, plugin_name, None)
 
88
        plugin = getattr(breezy.plugins, plugin_name, None)
89
89
        if plugin is not None:
90
90
            if getattr(plugin, submodule_name, None) is not None:
91
91
                delattr(plugin, submodule_name)
92
92
 
93
93
    def assertPluginUnknown(self, name):
94
 
        self.assertFalse(getattr(brzlib.plugins, name, None) is not None)
95
 
        self.assertFalse('brzlib.plugins.%s' % name in sys.modules)
 
94
        self.assertFalse(getattr(breezy.plugins, name, None) is not None)
 
95
        self.assertFalse('breezy.plugins.%s' % name in sys.modules)
96
96
 
97
97
    def assertPluginKnown(self, name):
98
 
        self.assertTrue(getattr(brzlib.plugins, name, None) is not None)
99
 
        self.assertTrue('brzlib.plugins.%s' % name in sys.modules)
 
98
        self.assertTrue(getattr(breezy.plugins, name, None) is not None)
 
99
        self.assertTrue('breezy.plugins.%s' % name in sys.modules)
100
100
 
101
101
 
102
102
class TestLoadingPlugins(BaseTestPlugins):
120
120
        os.mkdir('second')
121
121
        # write a plugin that will record when its loaded in the
122
122
        # tempattribute list.
123
 
        template = ("from brzlib.tests.test_plugins import TestLoadingPlugins\n"
 
123
        template = ("from breezy.tests.test_plugins import TestLoadingPlugins\n"
124
124
                    "TestLoadingPlugins.activeattributes[%r].append('%s')\n")
125
125
 
126
126
        outfile = open(os.path.join('first', 'plugin.py'), 'w')
138
138
            outfile.close()
139
139
 
140
140
        try:
141
 
            brzlib.plugin.load_from_path(['first', 'second'])
 
141
            breezy.plugin.load_from_path(['first', 'second'])
142
142
            self.assertEqual(['first'], self.activeattributes[tempattribute])
143
143
        finally:
144
144
            # remove the plugin 'plugin'
147
147
        self.assertPluginUnknown('plugin')
148
148
 
149
149
    def test_plugins_from_different_dirs_can_demand_load(self):
150
 
        self.assertFalse('brzlib.plugins.pluginone' in sys.modules)
151
 
        self.assertFalse('brzlib.plugins.plugintwo' in sys.modules)
 
150
        self.assertFalse('breezy.plugins.pluginone' in sys.modules)
 
151
        self.assertFalse('breezy.plugins.plugintwo' in sys.modules)
152
152
        # This test tests that having two plugins in different
153
153
        # directories with different names allows them both to be loaded, when
154
154
        # we do a direct import statement.
159
159
        # set a place for the plugins to record their loading, and at the same
160
160
        # time validate that the location the plugins should record to is
161
161
        # valid and correct.
162
 
        brzlib.tests.test_plugins.TestLoadingPlugins.activeattributes \
 
162
        breezy.tests.test_plugins.TestLoadingPlugins.activeattributes \
163
163
            [tempattribute] = []
164
164
        self.assertTrue(tempattribute in self.activeattributes)
165
165
        # create two plugin directories
167
167
        os.mkdir('second')
168
168
        # write plugins that will record when they are loaded in the
169
169
        # tempattribute list.
170
 
        template = ("from brzlib.tests.test_plugins import TestLoadingPlugins\n"
 
170
        template = ("from breezy.tests.test_plugins import TestLoadingPlugins\n"
171
171
                    "TestLoadingPlugins.activeattributes[%r].append('%s')\n")
172
172
 
173
173
        outfile = open(os.path.join('first', 'pluginone.py'), 'w')
184
184
        finally:
185
185
            outfile.close()
186
186
 
187
 
        oldpath = brzlib.plugins.__path__
 
187
        oldpath = breezy.plugins.__path__
188
188
        try:
189
 
            self.assertFalse('brzlib.plugins.pluginone' in sys.modules)
190
 
            self.assertFalse('brzlib.plugins.plugintwo' in sys.modules)
191
 
            brzlib.plugins.__path__ = ['first', 'second']
192
 
            exec "import brzlib.plugins.pluginone"
 
189
            self.assertFalse('breezy.plugins.pluginone' in sys.modules)
 
190
            self.assertFalse('breezy.plugins.plugintwo' in sys.modules)
 
191
            breezy.plugins.__path__ = ['first', 'second']
 
192
            exec "import breezy.plugins.pluginone"
193
193
            self.assertEqual(['first'], self.activeattributes[tempattribute])
194
 
            exec "import brzlib.plugins.plugintwo"
 
194
            exec "import breezy.plugins.plugintwo"
195
195
            self.assertEqual(['first', 'second'],
196
196
                self.activeattributes[tempattribute])
197
197
        finally:
212
212
        # set a place for the plugin to record its loading, and at the same
213
213
        # time validate that the location the plugin should record to is
214
214
        # valid and correct.
215
 
        brzlib.tests.test_plugins.TestLoadingPlugins.activeattributes \
 
215
        breezy.tests.test_plugins.TestLoadingPlugins.activeattributes \
216
216
            [tempattribute] = []
217
217
        self.assertTrue(tempattribute in self.activeattributes)
218
218
        # create a directory for the plugin
219
219
        os.mkdir('plugin_test')
220
220
        # write a plugin that will record when its loaded in the
221
221
        # tempattribute list.
222
 
        template = ("from brzlib.tests.test_plugins import TestLoadingPlugins\n"
 
222
        template = ("from breezy.tests.test_plugins import TestLoadingPlugins\n"
223
223
                    "TestLoadingPlugins.activeattributes[%r].append('%s')\n")
224
224
 
225
225
        outfile = open(os.path.join('plugin_test', 'ts_plugin.py'), 'w')
230
230
            outfile.close()
231
231
 
232
232
        try:
233
 
            brzlib.plugin.load_from_path(['plugin_test'+os.sep])
 
233
            breezy.plugin.load_from_path(['plugin_test'+os.sep])
234
234
            self.assertEqual(['plugin'], self.activeattributes[tempattribute])
235
235
        finally:
236
236
            del self.activeattributes[tempattribute]
251
251
            log.addHandler(handler)
252
252
            try:
253
253
                try:
254
 
                    brzlib.plugin.load_from_path(['.'])
 
254
                    breezy.plugin.load_from_path(['.'])
255
255
                finally:
256
 
                    if 'brzlib.plugins.%s' % name in sys.modules:
257
 
                        del sys.modules['brzlib.plugins.%s' % name]
258
 
                    if getattr(brzlib.plugins, name, None):
259
 
                        delattr(brzlib.plugins, name)
 
256
                    if 'breezy.plugins.%s' % name in sys.modules:
 
257
                        del sys.modules['breezy.plugins.%s' % name]
 
258
                    if getattr(breezy.plugins, name, None):
 
259
                        delattr(breezy.plugins, name)
260
260
            finally:
261
261
                # Stop capturing output
262
262
                handler.flush()
277
277
        name = 'wants100.py'
278
278
        f = file(name, 'w')
279
279
        try:
280
 
            f.write("import brzlib.api\n"
281
 
                "brzlib.api.require_any_api(brzlib, [(1, 0, 0)])\n")
 
280
            f.write("import breezy.api\n"
 
281
                "breezy.api.require_any_api(breezy, [(1, 0, 0)])\n")
282
282
        finally:
283
283
            f.close()
284
284
        log = self.load_and_capture(name)
305
305
class TestPlugins(BaseTestPlugins):
306
306
 
307
307
    def setup_plugin(self, source=""):
308
 
        # This test tests a new plugin appears in brzlib.plugin.plugins().
 
308
        # This test tests a new plugin appears in breezy.plugin.plugins().
309
309
        # check the plugin is not loaded already
310
310
        self.assertPluginUnknown('plugin')
311
311
        # write a plugin that _cannot_ fail to load.
321
321
        self.setup_plugin()
322
322
        self.assertPluginKnown('plugin')
323
323
        p = plugin.plugins()['plugin']
324
 
        self.assertIsInstance(p, brzlib.plugin.PlugIn)
 
324
        self.assertIsInstance(p, breezy.plugin.PlugIn)
325
325
        self.assertEqual(p.module, plugins.plugin)
326
326
 
327
327
    def test_trivial_plugin_get_path(self):
401
401
 
402
402
    def test_no_version_info___version__(self):
403
403
        self.setup_plugin()
404
 
        plugin = brzlib.plugin.plugins()['plugin']
 
404
        plugin = breezy.plugin.plugins()['plugin']
405
405
        self.assertEqual("unknown", plugin.__version__)
406
406
 
407
407
    def test_str__version__with_version_info(self):
408
408
        self.setup_plugin("version_info = '1.2.3'")
409
 
        plugin = brzlib.plugin.plugins()['plugin']
 
409
        plugin = breezy.plugin.plugins()['plugin']
410
410
        self.assertEqual("1.2.3", plugin.__version__)
411
411
 
412
412
    def test_noniterable__version__with_version_info(self):
413
413
        self.setup_plugin("version_info = (1)")
414
 
        plugin = brzlib.plugin.plugins()['plugin']
 
414
        plugin = breezy.plugin.plugins()['plugin']
415
415
        self.assertEqual("1", plugin.__version__)
416
416
 
417
417
    def test_1__version__with_version_info(self):
418
418
        self.setup_plugin("version_info = (1,)")
419
 
        plugin = brzlib.plugin.plugins()['plugin']
 
419
        plugin = breezy.plugin.plugins()['plugin']
420
420
        self.assertEqual("1", plugin.__version__)
421
421
 
422
422
    def test_1_2__version__with_version_info(self):
423
423
        self.setup_plugin("version_info = (1, 2)")
424
 
        plugin = brzlib.plugin.plugins()['plugin']
 
424
        plugin = breezy.plugin.plugins()['plugin']
425
425
        self.assertEqual("1.2", plugin.__version__)
426
426
 
427
427
    def test_1_2_3__version__with_version_info(self):
428
428
        self.setup_plugin("version_info = (1, 2, 3)")
429
 
        plugin = brzlib.plugin.plugins()['plugin']
 
429
        plugin = breezy.plugin.plugins()['plugin']
430
430
        self.assertEqual("1.2.3", plugin.__version__)
431
431
 
432
432
    def test_candidate__version__with_version_info(self):
433
433
        self.setup_plugin("version_info = (1, 2, 3, 'candidate', 1)")
434
 
        plugin = brzlib.plugin.plugins()['plugin']
 
434
        plugin = breezy.plugin.plugins()['plugin']
435
435
        self.assertEqual("1.2.3rc1", plugin.__version__)
436
436
 
437
437
    def test_dev__version__with_version_info(self):
438
438
        self.setup_plugin("version_info = (1, 2, 3, 'dev', 0)")
439
 
        plugin = brzlib.plugin.plugins()['plugin']
 
439
        plugin = breezy.plugin.plugins()['plugin']
440
440
        self.assertEqual("1.2.3dev", plugin.__version__)
441
441
 
442
442
    def test_dev_fallback__version__with_version_info(self):
443
443
        self.setup_plugin("version_info = (1, 2, 3, 'dev', 4)")
444
 
        plugin = brzlib.plugin.plugins()['plugin']
 
444
        plugin = breezy.plugin.plugins()['plugin']
445
445
        self.assertEqual("1.2.3dev4", plugin.__version__)
446
446
 
447
447
    def test_final__version__with_version_info(self):
448
448
        self.setup_plugin("version_info = (1, 2, 3, 'final', 0)")
449
 
        plugin = brzlib.plugin.plugins()['plugin']
 
449
        plugin = breezy.plugin.plugins()['plugin']
450
450
        self.assertEqual("1.2.3", plugin.__version__)
451
451
 
452
452
    def test_final_fallback__version__with_version_info(self):
453
453
        self.setup_plugin("version_info = (1, 2, 3, 'final', 2)")
454
 
        plugin = brzlib.plugin.plugins()['plugin']
 
454
        plugin = breezy.plugin.plugins()['plugin']
455
455
        self.assertEqual("1.2.3.2", plugin.__version__)
456
456
 
457
457
 
471
471
    def test_plugin_help_builtins_unaffected(self):
472
472
        # Check we don't get false positives
473
473
        help_commands = self.split_help_commands()
474
 
        for cmd_name in brzlib.commands.builtin_command_names():
475
 
            if cmd_name in brzlib.commands.plugin_command_names():
 
474
        for cmd_name in breezy.commands.builtin_command_names():
 
475
            if cmd_name in breezy.commands.plugin_command_names():
476
476
                continue
477
477
            try:
478
 
                help = brzlib.commands.get_cmd_object(cmd_name).get_help_text()
 
478
                help = breezy.commands.get_cmd_object(cmd_name).get_help_text()
479
479
            except NotImplementedError:
480
480
                # some commands have no help
481
481
                pass
492
492
        os.mkdir('plugin_test')
493
493
        f = open(osutils.pathjoin('plugin_test', 'myplug.py'), 'w')
494
494
        f.write("""\
495
 
from brzlib import commands
 
495
from breezy import commands
496
496
class cmd_myplug(commands.Command):
497
497
    __doc__ = '''Just a simple test plugin.'''
498
498
    aliases = ['mplg']
505
505
 
506
506
        try:
507
507
            # Check its help
508
 
            brzlib.plugin.load_from_path(['plugin_test'])
509
 
            brzlib.commands.register_command( brzlib.plugins.myplug.cmd_myplug)
 
508
            breezy.plugin.load_from_path(['plugin_test'])
 
509
            breezy.commands.register_command( breezy.plugins.myplug.cmd_myplug)
510
510
            help = self.run_bzr('help myplug')[0]
511
511
            self.assertContainsRe(help, 'plugin "myplug"')
512
512
            help = self.split_help_commands()['myplug']
513
513
            self.assertContainsRe(help, '\[myplug\]')
514
514
        finally:
515
515
            # unregister command
516
 
            if 'myplug' in brzlib.commands.plugin_cmds:
517
 
                brzlib.commands.plugin_cmds.remove('myplug')
 
516
            if 'myplug' in breezy.commands.plugin_cmds:
 
517
                breezy.commands.plugin_cmds.remove('myplug')
518
518
            # remove the plugin 'myplug'
519
 
            if getattr(brzlib.plugins, 'myplug', None):
520
 
                delattr(brzlib.plugins, 'myplug')
 
519
            if getattr(breezy.plugins, 'myplug', None):
 
520
                delattr(breezy.plugins, 'myplug')
521
521
 
522
522
 
523
523
class TestHelpIndex(tests.TestCase):
536
536
        index = plugin.PluginsHelpIndex()
537
537
        # make a new plugin here for this test, even if we're run with
538
538
        # --no-plugins
539
 
        self.assertFalse(sys.modules.has_key('brzlib.plugins.demo_module'))
540
 
        demo_module = FakeModule('', 'brzlib.plugins.demo_module')
541
 
        sys.modules['brzlib.plugins.demo_module'] = demo_module
 
539
        self.assertFalse(sys.modules.has_key('breezy.plugins.demo_module'))
 
540
        demo_module = FakeModule('', 'breezy.plugins.demo_module')
 
541
        sys.modules['breezy.plugins.demo_module'] = demo_module
542
542
        try:
543
543
            topics = index.get_topics('demo_module')
544
544
            self.assertEqual(1, len(topics))
545
545
            self.assertIsInstance(topics[0], plugin.ModuleHelpTopic)
546
546
            self.assertEqual(demo_module, topics[0].module)
547
547
        finally:
548
 
            del sys.modules['brzlib.plugins.demo_module']
 
548
            del sys.modules['breezy.plugins.demo_module']
549
549
 
550
550
    def test_get_topics_no_topic(self):
551
551
        """Searching for something that is not a plugin returns []."""
562
562
    def test_get_plugin_topic_with_prefix(self):
563
563
        """Searching for plugins/demo_module returns help."""
564
564
        index = plugin.PluginsHelpIndex()
565
 
        self.assertFalse(sys.modules.has_key('brzlib.plugins.demo_module'))
566
 
        demo_module = FakeModule('', 'brzlib.plugins.demo_module')
567
 
        sys.modules['brzlib.plugins.demo_module'] = demo_module
 
565
        self.assertFalse(sys.modules.has_key('breezy.plugins.demo_module'))
 
566
        demo_module = FakeModule('', 'breezy.plugins.demo_module')
 
567
        sys.modules['breezy.plugins.demo_module'] = demo_module
568
568
        try:
569
569
            topics = index.get_topics('plugins/demo_module')
570
570
            self.assertEqual(1, len(topics))
571
571
            self.assertIsInstance(topics[0], plugin.ModuleHelpTopic)
572
572
            self.assertEqual(demo_module, topics[0].module)
573
573
        finally:
574
 
            del sys.modules['brzlib.plugins.demo_module']
 
574
            del sys.modules['breezy.plugins.demo_module']
575
575
 
576
576
 
577
577
class FakeModule(object):
620
620
 
621
621
    def test_get_help_topic(self):
622
622
        """The help topic for a plugin is its module name."""
623
 
        mod = FakeModule('two lines of help\nand more', 'brzlib.plugins.demo')
 
623
        mod = FakeModule('two lines of help\nand more', 'breezy.plugins.demo')
624
624
        topic = plugin.ModuleHelpTopic(mod)
625
625
        self.assertEqual('demo', topic.get_help_topic())
626
626
        mod = FakeModule('two lines of help\nand more',
627
 
                         'brzlib.plugins.foo_bar')
 
627
                         'breezy.plugins.foo_bar')
628
628
        topic = plugin.ModuleHelpTopic(mod)
629
629
        self.assertEqual('foo_bar', topic.get_help_topic())
630
630
 
633
633
 
634
634
    def setUp(self):
635
635
        super(TestLoadFromPath, self).setUp()
636
 
        # Change brzlib.plugin to think no plugins have been loaded yet.
637
 
        self.overrideAttr(brzlib.plugins, '__path__', [])
 
636
        # Change breezy.plugin to think no plugins have been loaded yet.
 
637
        self.overrideAttr(breezy.plugins, '__path__', [])
638
638
        self.overrideAttr(plugin, '_loaded', False)
639
639
 
640
640
        # Monkey-patch load_from_path to stop it from actually loading anything.
642
642
 
643
643
    def test_set_plugins_path_with_args(self):
644
644
        plugin.set_plugins_path(['a', 'b'])
645
 
        self.assertEqual(['a', 'b'], brzlib.plugins.__path__)
 
645
        self.assertEqual(['a', 'b'], breezy.plugins.__path__)
646
646
 
647
647
    def test_set_plugins_path_defaults(self):
648
648
        plugin.set_plugins_path()
649
649
        self.assertEqual(plugin.get_standard_plugins_path(),
650
 
                         brzlib.plugins.__path__)
 
650
                         breezy.plugins.__path__)
651
651
 
652
652
    def test_get_standard_plugins_path(self):
653
653
        path = plugin.get_standard_plugins_path()
674
674
 
675
675
    def test_load_plugins(self):
676
676
        plugin.load_plugins(['.'])
677
 
        self.assertEqual(brzlib.plugins.__path__, ['.'])
 
677
        self.assertEqual(breezy.plugins.__path__, ['.'])
678
678
        # subsequent loads are no-ops
679
679
        plugin.load_plugins(['foo'])
680
 
        self.assertEqual(brzlib.plugins.__path__, ['.'])
 
680
        self.assertEqual(breezy.plugins.__path__, ['.'])
681
681
 
682
682
    def test_load_plugins_default(self):
683
683
        plugin.load_plugins()
684
684
        path = plugin.get_standard_plugins_path()
685
 
        self.assertEqual(path, brzlib.plugins.__path__)
 
685
        self.assertEqual(path, breezy.plugins.__path__)
686
686
 
687
687
 
688
688
class TestEnvPluginPath(tests.TestCase):
793
793
        self.overrideEnv('BRZ_DISABLE_PLUGINS', 'test_foo')
794
794
        plugin.set_plugins_path(['.'])
795
795
        try:
796
 
            import brzlib.plugins.test_foo
 
796
            import breezy.plugins.test_foo
797
797
        except ImportError:
798
798
            pass
799
799
        self.assertPluginUnknown('test_foo')
803
803
        plugin.load_plugins(['.'])
804
804
        self.assertPluginKnown('test_foo')
805
805
        self.assertDocstring("This is the doc for test_foo",
806
 
                             brzlib.plugins.test_foo)
 
806
                             breezy.plugins.test_foo)
807
807
 
808
808
    def test_not_loaded(self):
809
809
        self.warnings = []
866
866
    def assertTestFooLoadedFrom(self, path):
867
867
        self.assertPluginKnown('test_foo')
868
868
        self.assertDocstring('This is the doc for test_foo',
869
 
                             brzlib.plugins.test_foo)
870
 
        self.assertEqual(path, brzlib.plugins.test_foo.dir_source)
 
869
                             breezy.plugins.test_foo)
 
870
        self.assertEqual(path, breezy.plugins.test_foo.dir_source)
871
871
 
872
872
    def test_regular_load(self):
873
873
        plugin.load_plugins(['standard'])
877
877
        self.overrideEnv('BRZ_PLUGINS_AT', 'test_foo@non-standard-dir')
878
878
        plugin.set_plugins_path(['standard'])
879
879
        try:
880
 
            import brzlib.plugins.test_foo
 
880
            import breezy.plugins.test_foo
881
881
        except ImportError:
882
882
            pass
883
883
        self.assertTestFooLoadedFrom('non-standard-dir')
892
892
        plugin.load_plugins(['standard'])
893
893
        self.assertTestFooLoadedFrom('non-standard-dir')
894
894
        self.assertIsSameRealPath('non-standard-dir/__init__.py',
895
 
                                  brzlib.plugins.test_foo.__file__)
 
895
                                  breezy.plugins.test_foo.__file__)
896
896
 
897
897
        # Try importing again now that the source has been compiled
898
898
        self._unregister_plugin('test_foo')
904
904
        else:
905
905
            suffix = 'pyo'
906
906
        self.assertIsSameRealPath('non-standard-dir/__init__.%s' % suffix,
907
 
                                  brzlib.plugins.test_foo.__file__)
 
907
                                  breezy.plugins.test_foo.__file__)
908
908
 
909
909
    def test_submodule_loading(self):
910
910
        # We create an additional directory under the one for test_foo
913
913
                        'test_foo', 'test_bar')
914
914
        self.overrideEnv('BRZ_PLUGINS_AT', 'test_foo@non-standard-dir')
915
915
        plugin.set_plugins_path(['standard'])
916
 
        import brzlib.plugins.test_foo
917
 
        self.assertEqual('brzlib.plugins.test_foo',
918
 
                         brzlib.plugins.test_foo.__package__)
919
 
        import brzlib.plugins.test_foo.test_bar
 
916
        import breezy.plugins.test_foo
 
917
        self.assertEqual('breezy.plugins.test_foo',
 
918
                         breezy.plugins.test_foo.__package__)
 
919
        import breezy.plugins.test_foo.test_bar
920
920
        self.assertIsSameRealPath('non-standard-dir/test_bar/__init__.py',
921
 
                                  brzlib.plugins.test_foo.test_bar.__file__)
 
921
                                  breezy.plugins.test_foo.test_bar.__file__)
922
922
 
923
923
    def test_relative_submodule_loading(self):
924
924
        self.create_plugin_package('test_foo', dir='another-dir', source='''
930
930
                        'test_foo', 'test_bar')
931
931
        self.overrideEnv('BRZ_PLUGINS_AT', 'test_foo@another-dir')
932
932
        plugin.set_plugins_path(['standard'])
933
 
        import brzlib.plugins.test_foo
934
 
        self.assertEqual('brzlib.plugins.test_foo',
935
 
                         brzlib.plugins.test_foo.__package__)
 
933
        import breezy.plugins.test_foo
 
934
        self.assertEqual('breezy.plugins.test_foo',
 
935
                         breezy.plugins.test_foo.__package__)
936
936
        self.assertIsSameRealPath('another-dir/test_bar/__init__.py',
937
 
                                  brzlib.plugins.test_foo.test_bar.__file__)
 
937
                                  breezy.plugins.test_foo.test_bar.__file__)
938
938
 
939
939
    def test_loading_from___init__only(self):
940
940
        # We rename the existing __init__.py file to ensure that we don't load