~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_plugins.py

  • Committer: John Arbash Meinel
  • Date: 2008-07-08 14:55:19 UTC
  • mfrom: (3530 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3532.
  • Revision ID: john@arbash-meinel.com-20080708145519-paqg4kjwbpgs2xmq
Merge bzr.dev 3530

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
import bzrlib.commands
33
33
import bzrlib.help
34
34
from bzrlib.symbol_versioning import one_three
35
 
from bzrlib.tests import TestCase, TestCaseInTempDir
 
35
from bzrlib.tests import (
 
36
    TestCase,
 
37
    TestCaseInTempDir,
 
38
    TestUtil,
 
39
    )
36
40
from bzrlib.osutils import pathjoin, abspath, normpath
37
41
 
38
42
 
191
195
 
192
196
    def test_plugin_with_bad_name_does_not_load(self):
193
197
        # Create badly-named plugin
194
 
        file('bad plugin-name..py', 'w').close()
 
198
        file('bzr-bad plugin-name..py', 'w').close()
195
199
 
196
200
        # Capture output
197
201
        stream = StringIO()
207
211
        log.removeHandler(handler)
208
212
 
209
213
        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_'\.")
 
214
            r"Unable to load 'bzr-bad plugin-name\.' in '\.' as a plugin "
 
215
            "because the file path isn't a valid module name; try renaming "
 
216
            "it to 'bad_plugin_name_'\.")
213
217
 
214
218
        stream.close()
215
219
 
282
286
        plugin = bzrlib.plugin.plugins()['plugin']
283
287
        self.assertEqual('foo', plugin.test_suite())
284
288
 
 
289
    def test_no_load_plugin_tests_gives_None_for_load_plugin_tests(self):
 
290
        self.setup_plugin()
 
291
        loader = TestUtil.TestLoader()
 
292
        plugin = bzrlib.plugin.plugins()['plugin']
 
293
        self.assertEqual(None, plugin.load_plugin_tests(loader))
 
294
 
 
295
    def test_load_plugin_tests_gives_load_plugin_tests_result(self):
 
296
        source = """
 
297
def load_tests(standard_tests, module, loader):
 
298
    return 'foo'"""
 
299
        self.setup_plugin(source)
 
300
        loader = TestUtil.TestLoader()
 
301
        plugin = bzrlib.plugin.plugins()['plugin']
 
302
        self.assertEqual('foo', plugin.load_plugin_tests(loader))
 
303
 
285
304
    def test_no_version_info(self):
286
305
        self.setup_plugin()
287
306
        plugin = bzrlib.plugin.plugins()['plugin']
428
447
            bzrlib.plugin.set_plugins_path()
429
448
            expected_path = ['first', 'second',
430
449
                os.path.dirname(bzrlib.plugins.__file__)]
431
 
            self.assertEqual(expected_path, bzrlib.plugins.__path__)
 
450
            self.assertEqual(expected_path,
 
451
                bzrlib.plugins.__path__[:len(expected_path)])
432
452
        finally:
433
453
            bzrlib.plugins.__path__ = old_path
434
 
            if old_env != None:
 
454
            if old_env is not None:
435
455
                os.environ['BZR_PLUGIN_PATH'] = old_env
436
456
            else:
437
457
                del os.environ['BZR_PLUGIN_PATH']
438
458
 
 
459
 
439
460
class TestHelpIndex(tests.TestCase):
440
461
    """Tests for the PluginsHelpIndex class."""
441
462