750
by Martin Pool
- stubbed-out tests for python plugins |
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 |
||
1143
by Martin Pool
- remove dead code and remove some small errors (pychecker) |
20 |
|
21 |
||
22 |
# **************************************************
|
|
750
by Martin Pool
- stubbed-out tests for python plugins |
23 |
# NOT RUN YET
|
1143
by Martin Pool
- remove dead code and remove some small errors (pychecker) |
24 |
# **************************************************
|
25 |
||
750
by Martin Pool
- stubbed-out tests for python plugins |
26 |
|
27 |
||
28 |
||
29 |
||
30 |
||
31 |
||
32 |
||
1141
by Martin Pool
- rename FunctionalTest to TestCaseInTempDir |
33 |
from bzrlib.selftest import TestCaseInTempDir |
34 |
||
35 |
||
1143
by Martin Pool
- remove dead code and remove some small errors (pychecker) |
36 |
class PluginTest(TestCaseInTempDir): |
750
by Martin Pool
- stubbed-out tests for python plugins |
37 |
"""Create an external plugin and test loading."""
|
1102
by Martin Pool
- merge test refactoring from robertc |
38 |
def test_plugin_loading(self): |
750
by Martin Pool
- stubbed-out tests for python plugins |
39 |
import os |
40 |
||
41 |
orig_help = self.backtick('bzr help commands') # No plugins yet |
|
42 |
os.mkdir('plugin_test') |
|
43 |
f = open(os.path.join('plugin_test', 'myplug.py'), 'wt') |
|
44 |
f.write(PLUGIN_TEXT) |
|
45 |
f.close() |
|
46 |
||
47 |
newhelp = backtick('bzr help commands') |
|
48 |
assert newhelp.startswith('You have been overridden\n') |
|
49 |
# We added a line, but the rest should work
|
|
50 |
assert newhelp[25:] == help |
|
51 |
||
52 |
assert backtick('bzr commit -m test') == "I'm sorry dave, you can't do that\n" |
|
53 |
||
54 |
shutil.rmtree('plugin_test') |
|
55 |
||
56 |
||
57 |
||
58 |
||
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
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 |
# """
|