~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_plugins.py

  • Committer: Alexander Belchenko
  • Date: 2007-11-19 22:54:30 UTC
  • mfrom: (3006 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3008.
  • Revision ID: bialix@ukr.net-20071119225430-x0ewosrsagis0yno
merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
# affects the global state of the process.  See bzrlib/plugins.py for more
21
21
# comments.
22
22
 
 
23
import logging
23
24
import os
24
25
from StringIO import StringIO
25
26
import sys
188
189
                del bzrlib.plugins.ts_plugin
189
190
        self.failIf(getattr(bzrlib.plugins, 'ts_plugin', None))
190
191
 
 
192
    def test_plugin_with_bad_name_does_not_load(self):
 
193
        # Create badly-named plugin
 
194
        file('bad plugin-name..py', 'w').close()
 
195
 
 
196
        # Capture output
 
197
        stream = StringIO()
 
198
        handler = logging.StreamHandler(stream)
 
199
        log = logging.getLogger('bzr')
 
200
        log.addHandler(handler)
 
201
 
 
202
        bzrlib.plugin.load_from_dir('.')
 
203
 
 
204
        # Stop capturing output
 
205
        handler.flush()
 
206
        handler.close()
 
207
        log.removeHandler(handler)
 
208
 
 
209
        self.assertContainsRe(stream.getvalue(),
 
210
            r"Unable to load 'bad plugin-name\.' in '\.' as a plugin because"
 
211
            " file path isn't a valid module name; try renaming it to"
 
212
            " 'bad_plugin_name_'\.")
 
213
 
 
214
        stream.close()
 
215
 
191
216
 
192
217
class TestAllPlugins(TestCaseInTempDir):
193
218