~ubuntu-branches/ubuntu/hardy/bzr/hardy-updates

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testplugins.py

  • Committer: Bazaar Package Importer
  • Author(s): Jeff Bailey
  • Date: 2005-11-07 13:17:53 UTC
  • Revision ID: james.westby@ubuntu.com-20051107131753-qsy145z1rfug5i27
Tags: upstream-0.6.2
ImportĀ upstreamĀ versionĀ 0.6.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2005 by Canonical Ltd
 
2
 
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
 
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
 
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
 
 
17
 
 
18
"""Tests for plugins"""
 
19
 
 
20
# XXX: There are no plugin tests at the moment because the plugin module
 
21
# affects the global state of the process.  See bzrlib/plugins.py for more
 
22
# comments.
 
23
 
 
24
import os
 
25
 
 
26
from bzrlib.selftest import TestCaseInTempDir
 
27
 
 
28
class PluginTest(TestCaseInTempDir):
 
29
    """Create an external plugin and test loading."""
 
30
#    def test_plugin_loading(self):
 
31
#        orig_help = self.run_bzr_captured('bzr help commands')[0]
 
32
#        os.mkdir('plugin_test')
 
33
#        f = open(os.path.join('plugin_test', 'myplug.py'), 'wt')
 
34
#        f.write(PLUGIN_TEXT)
 
35
#        f.close()
 
36
#        newhelp = self.run_bzr_captured('bzr help commands')[0]
 
37
#        assert newhelp.startswith('You have been overridden\n')
 
38
#        # We added a line, but the rest should work
 
39
#        assert newhelp[25:] == help
 
40
#
 
41
#        assert backtick('bzr commit -m test') == "I'm sorry dave, you can't do that\n"
 
42
#
 
43
#        shutil.rmtree('plugin_test')
 
44
#
 
45
 
 
46
#         os.environ['BZRPLUGINPATH'] = os.path.abspath('plugin_test')
 
47
#         help = backtick('bzr help commands')
 
48
#         assert help.find('myplug') != -1
 
49
#         assert help.find('Just a simple test plugin.') != -1
 
50
 
 
51
 
 
52
#         assert backtick('bzr myplug') == 'Hello from my plugin\n'
 
53
#         assert backtick('bzr mplg') == 'Hello from my plugin\n'
 
54
 
 
55
#         f = open(os.path.join('plugin_test', 'override.py'), 'wb')
 
56
#         f.write("""import bzrlib, bzrlib.commands
 
57
#     class cmd_commit(bzrlib.commands.cmd_commit):
 
58
#         '''Commit changes into a new revision.'''
 
59
#         def run(self, *args, **kwargs):
 
60
#             print "I'm sorry dave, you can't do that"
 
61
 
 
62
#     class cmd_help(bzrlib.commands.cmd_help):
 
63
#         '''Show help on a command or other topic.'''
 
64
#         def run(self, *args, **kwargs):
 
65
#             print "You have been overridden"
 
66
#             bzrlib.commands.cmd_help.run(self, *args, **kwargs)
 
67
 
 
68
#         """
 
69
 
 
70
PLUGIN_TEXT = """\
 
71
import bzrlib.commands
 
72
class cmd_myplug(bzrlib.commands.Command):
 
73
    '''Just a simple test plugin.'''
 
74
    aliases = ['mplg']
 
75
    def run(self):
 
76
        print 'Hello from my plugin'
 
77
"""