51
50
return self.runcmd(['python', self.BZRPATH,] + args,
56
class MvCommand(BzrTestBase):
58
"""Test two modes of operation for mv"""
59
b = Branch('.', init=True)
60
self.build_tree(['a', 'c', 'subdir/'])
61
self.run_bzr('mv', 'a', 'b')
62
self.run_bzr('mv', 'b', 'subdir')
63
self.run_bzr('mv', 'subdir/b', 'a')
64
self.run_bzr('mv', 'a', 'b', 'subdir')
65
self.run_bzr('mv', 'subdir/a', 'subdir/newa')
69
class TestVersion(BzrTestBase):
70
"""Check output from version command and master option is reasonable"""
72
# output is intentionally passed through to stdout so that we
73
# can see the version being tested
74
from cStringIO import StringIO
77
sys.stdout = tmp_out = StringIO()
79
self.run_bzr('version')
83
output = tmp_out.getvalue()
84
self.log('bzr version output:')
87
self.assert_(output.startswith('bzr (bazaar-ng) '))
88
self.assertNotEqual(output.index('Canonical'), -1)
90
# make sure --version is consistent
92
sys.stdout = tmp_out = StringIO()
94
self.run_bzr('--version')
98
self.log('bzr --version output:')
99
self.log(tmp_out.getvalue())
101
self.assertEquals(output, tmp_out.getvalue())
107
class HelpCommands(ExternalBase):
53
class TestCommands(ExternalBase):
55
def test_help_commands(self):
109
56
self.runbzr('--help')
110
57
self.runbzr('help')
111
58
self.runbzr('help commands')
112
59
self.runbzr('help help')
113
60
self.runbzr('commit -h')
116
class InitBranch(ExternalBase):
62
def test_init_branch(self):
119
64
self.runbzr(['init'])
122
class UserIdentity(ExternalBase):
66
def test_whoami(self):
124
67
# this should always identify something, if only "john@localhost"
125
68
self.runbzr("whoami")
126
69
self.runbzr("whoami --email")
128
71
self.assertEquals(self.runbzr("whoami --email",
129
72
backtick=True).count('@'), 1)
131
class UserIdentityBranch(ExternalBase):
133
# tests branch specific user identity
74
def test_whoami_branch(self):
75
"""branch specific user identity works."""
134
76
self.runbzr('init')
135
77
f = file('.bzr/email', 'wt')
136
78
f.write('Branch Identity <branch@identi.ty>')
140
82
self.assertTrue(whoami.startswith('Branch Identity <branch@identi.ty>'))
141
83
self.assertTrue(whoami_email.startswith('branch@identi.ty'))
144
class InvalidCommands(ExternalBase):
85
def test_invalid_commands(self):
146
86
self.runbzr("pants", retcode=1)
147
87
self.runbzr("--pants off", retcode=1)
148
88
self.runbzr("diff --message foo", retcode=1)
152
class EmptyCommit(ExternalBase):
90
def test_empty_commit(self):
154
91
self.runbzr("init")
155
92
self.build_tree(['hello.txt'])
156
93
self.runbzr("commit -m empty", retcode=1)
157
94
self.runbzr("add hello.txt")
158
95
self.runbzr("commit -m added")
162
class IgnorePatterns(ExternalBase):
97
def test_ignore_patterns(self):
164
98
from bzrlib.branch import Branch
166
100
b = Branch('.', init=True)
191
125
self.runbzr('ignore garh')
192
126
self.assertEquals(list(b.unknowns()), [])
193
127
assert file('.bzrignore', 'rb').read() == '*.blah\ngarh\n'
129
def test_revert(self):
132
file('hello', 'wt').write('foo')
133
self.runbzr('add hello')
134
self.runbzr('commit -m setup hello')
136
file('goodbye', 'wt').write('baz')
137
self.runbzr('add goodbye')
138
self.runbzr('commit -m setup goodbye')
140
file('hello', 'wt').write('bar')
141
file('goodbye', 'wt').write('qux')
142
self.runbzr('revert hello')
143
self.check_file_contents('hello', 'foo')
144
self.check_file_contents('goodbye', 'qux')
145
self.runbzr('revert')
146
self.check_file_contents('goodbye', 'baz')
148
def skipped_test_mv_modes(self):
149
"""Test two modes of operation for mv"""
150
from bzrlib.branch import Branch
151
b = Branch('.', init=True)
152
self.build_tree(['a', 'c', 'subdir/'])
153
self.run_bzr('mv', 'a', 'b')
154
self.run_bzr('mv', 'b', 'subdir')
155
self.run_bzr('mv', 'subdir/b', 'a')
156
self.run_bzr('mv', 'a', 'b', 'subdir')
157
self.run_bzr('mv', 'subdir/a', 'subdir/newa')
159
def test_main_version(self):
160
"""Check output from version command and master option is reasonable"""
161
# output is intentionally passed through to stdout so that we
162
# can see the version being tested
163
output = self.runbzr('version', backtick=1)
164
self.log('bzr version output:')
166
self.assert_(output.startswith('bzr (bazaar-ng) '))
167
self.assertNotEqual(output.index('Canonical'), -1)
168
# make sure --version is consistent
169
tmp_output = self.runbzr('--version', backtick=1)
170
self.log('bzr --version output:')
172
self.assertEquals(output, tmp_output)
198
174
class OldTests(ExternalBase):
199
175
# old tests moved from ./testbzr
201
177
from os import chdir, mkdir
202
178
from os.path import exists
373
class RevertCommand(ExternalBase):
377
file('hello', 'wt').write('foo')
378
self.runbzr('add hello')
379
self.runbzr('commit -m setup hello')
381
file('goodbye', 'wt').write('baz')
382
self.runbzr('add goodbye')
383
self.runbzr('commit -m setup goodbye')
385
file('hello', 'wt').write('bar')
386
file('goodbye', 'wt').write('qux')
387
self.runbzr('revert hello')
388
self.check_file_contents('hello', 'foo')
389
self.check_file_contents('goodbye', 'qux')
390
self.runbzr('revert')
391
self.check_file_contents('goodbye', 'baz')