/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-22 00:56:52 UTC
  • mfrom: (6621.2.26 py3_pokes)
  • Revision ID: jelmer@jelmer.uk-20170522005652-yjahcr9hwmjkno7n
Merge Python3 porting work ('py3 pokes')

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
# affects the global state of the process.  See breezy/plugins.py for more
21
21
# comments.
22
22
 
23
 
from cStringIO import StringIO
24
23
import logging
25
24
import os
26
25
import sys
27
26
 
28
27
import breezy
29
 
from breezy import (
 
28
from .. import (
30
29
    errors,
31
30
    osutils,
32
31
    plugin,
34
33
    tests,
35
34
    trace,
36
35
    )
 
36
from ..sixish import (
 
37
    BytesIO,
 
38
    )
37
39
 
38
40
 
39
41
# TODO: Write a test for plugin decoration of commands.
189
191
            self.assertFalse('breezy.plugins.pluginone' in sys.modules)
190
192
            self.assertFalse('breezy.plugins.plugintwo' in sys.modules)
191
193
            breezy.plugins.__path__ = ['first', 'second']
192
 
            exec "import breezy.plugins.pluginone"
 
194
            exec("import breezy.plugins.pluginone")
193
195
            self.assertEqual(['first'], self.activeattributes[tempattribute])
194
 
            exec "import breezy.plugins.plugintwo"
 
196
            exec("import breezy.plugins.plugintwo")
195
197
            self.assertEqual(['first', 'second'],
196
198
                self.activeattributes[tempattribute])
197
199
        finally:
244
246
        :return: A string with the log from the plugin loading call.
245
247
        """
246
248
        # Capture output
247
 
        stream = StringIO()
 
249
        stream = BytesIO()
248
250
        try:
249
251
            handler = logging.StreamHandler(stream)
250
252
            log = logging.getLogger('brz')
536
538
        index = plugin.PluginsHelpIndex()
537
539
        # make a new plugin here for this test, even if we're run with
538
540
        # --no-plugins
539
 
        self.assertFalse(sys.modules.has_key('breezy.plugins.demo_module'))
 
541
        self.assertFalse('breezy.plugins.demo_module' in sys.modules)
540
542
        demo_module = FakeModule('', 'breezy.plugins.demo_module')
541
543
        sys.modules['breezy.plugins.demo_module'] = demo_module
542
544
        try:
562
564
    def test_get_plugin_topic_with_prefix(self):
563
565
        """Searching for plugins/demo_module returns help."""
564
566
        index = plugin.PluginsHelpIndex()
565
 
        self.assertFalse(sys.modules.has_key('breezy.plugins.demo_module'))
 
567
        self.assertFalse('breezy.plugins.demo_module' in sys.modules)
566
568
        demo_module = FakeModule('', 'breezy.plugins.demo_module')
567
569
        sys.modules['breezy.plugins.demo_module'] = demo_module
568
570
        try: