~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/plugins.py

  • Committer: Martin Pool
  • Date: 2005-07-07 10:22:02 UTC
  • Revision ID: mbp@sourcefrog.net-20050707102201-2d2a13a25098b101
- rearrange and clear up merged weave

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
"""Tests for plugins"""
19
19
 
20
 
 
21
 
 
22
 
# **************************************************
23
20
# NOT RUN YET
24
 
# **************************************************
25
 
 
26
 
 
27
 
 
28
 
 
29
 
 
30
 
 
31
 
 
32
 
 
33
 
from bzrlib.selftest import TestCaseInTempDir
34
 
 
35
 
 
36
 
class PluginTest(TestCaseInTempDir):
 
21
 
 
22
 
 
23
 
 
24
 
 
25
 
 
26
 
 
27
 
 
28
from bzrlib.selftest import InTempDir
 
29
 
 
30
 
 
31
def PluginTest(InTempDir):
37
32
    """Create an external plugin and test loading."""
38
 
    def test_plugin_loading(self):
 
33
    def runTest(self):
39
34
        import os
40
35
        
41
36
        orig_help = self.backtick('bzr help commands') # No plugins yet
56
51
 
57
52
 
58
53
 
59
 
#         PLUGIN_TEXT = \
60
 
#         """import bzrlib, bzrlib.commands
61
 
#         class cmd_myplug(bzrlib.commands.Command):
62
 
#             '''Just a simple test plugin.'''
63
 
#             aliases = ['mplg']
64
 
#             def run(self):
65
 
#                 print 'Hello from my plugin'
66
 
#         """
67
 
#         f.close()
68
 
 
69
 
#         os.environ['BZRPLUGINPATH'] = os.path.abspath('plugin_test')
70
 
#         help = backtick('bzr help commands')
71
 
#         assert help.find('myplug') != -1
72
 
#         assert help.find('Just a simple test plugin.') != -1
73
 
 
74
 
 
75
 
#         assert backtick('bzr myplug') == 'Hello from my plugin\n'
76
 
#         assert backtick('bzr mplg') == 'Hello from my plugin\n'
77
 
 
78
 
#         f = open(os.path.join('plugin_test', 'override.py'), 'wb')
79
 
#         f.write("""import bzrlib, bzrlib.commands
80
 
#     class cmd_commit(bzrlib.commands.cmd_commit):
81
 
#         '''Commit changes into a new revision.'''
82
 
#         def run(self, *args, **kwargs):
83
 
#             print "I'm sorry dave, you can't do that"
84
 
 
85
 
#     class cmd_help(bzrlib.commands.cmd_help):
86
 
#         '''Show help on a command or other topic.'''
87
 
#         def run(self, *args, **kwargs):
88
 
#             print "You have been overridden"
89
 
#             bzrlib.commands.cmd_help.run(self, *args, **kwargs)
90
 
 
91
 
#         """
 
54
PLUGIN_TEXT = \
 
55
"""import bzrlib, bzrlib.commands
 
56
class cmd_myplug(bzrlib.commands.Command):
 
57
    '''Just a simple test plugin.'''
 
58
    aliases = ['mplg']
 
59
    def run(self):
 
60
        print 'Hello from my plugin'
 
61
""")
 
62
    f.close()
 
63
 
 
64
    os.environ['BZRPLUGINPATH'] = os.path.abspath('plugin_test')
 
65
    help = backtick('bzr help commands')
 
66
    assert help.find('myplug') != -1
 
67
    assert help.find('Just a simple test plugin.') != -1
 
68
 
 
69
 
 
70
    assert backtick('bzr myplug') == 'Hello from my plugin\n'
 
71
    assert backtick('bzr mplg') == 'Hello from my plugin\n'
 
72
 
 
73
    f = open(os.path.join('plugin_test', 'override.py'), 'wb')
 
74
    f.write("""import bzrlib, bzrlib.commands
 
75
class cmd_commit(bzrlib.commands.cmd_commit):
 
76
    '''Commit changes into a new revision.'''
 
77
    def run(self, *args, **kwargs):
 
78
        print "I'm sorry dave, you can't do that"
 
79
 
 
80
class cmd_help(bzrlib.commands.cmd_help):
 
81
    '''Show help on a command or other topic.'''
 
82
    def run(self, *args, **kwargs):
 
83
        print "You have been overridden"
 
84
        bzrlib.commands.cmd_help.run(self, *args, **kwargs)
 
85
 
 
86
    """