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'])
123
class UserIdentity(ExternalBase):
66
def test_whoami(self):
125
67
# this should always identify something, if only "john@localhost"
126
68
self.runbzr("whoami")
127
69
self.runbzr("whoami --email")
129
71
self.assertEquals(self.runbzr("whoami --email",
130
72
backtick=True).count('@'), 1)
132
class UserIdentityBranch(ExternalBase):
134
# tests branch specific user identity
74
def test_whoami_branch(self):
75
"""branch specific user identity works."""
135
76
self.runbzr('init')
136
77
f = file('.bzr/email', 'wt')
137
78
f.write('Branch Identity <branch@identi.ty>')
141
82
self.assertTrue(whoami.startswith('Branch Identity <branch@identi.ty>'))
142
83
self.assertTrue(whoami_email.startswith('branch@identi.ty'))
145
class InvalidCommands(ExternalBase):
85
def test_invalid_commands(self):
147
86
self.runbzr("pants", retcode=1)
148
87
self.runbzr("--pants off", retcode=1)
149
88
self.runbzr("diff --message foo", retcode=1)
153
class EmptyCommit(ExternalBase):
90
def test_empty_commit(self):
155
91
self.runbzr("init")
156
92
self.build_tree(['hello.txt'])
157
93
self.runbzr("commit -m empty", retcode=1)
158
94
self.runbzr("add hello.txt")
159
95
self.runbzr("commit -m added")
163
class IgnorePatterns(ExternalBase):
97
def test_ignore_patterns(self):
165
98
from bzrlib.branch import Branch
167
100
b = Branch('.', init=True)
192
125
self.runbzr('ignore garh')
193
126
self.assertEquals(list(b.unknowns()), [])
194
127
assert file('.bzrignore', 'rb').read() == '*.blah\ngarh\n'
129
def test_revert(self):
134
file('hello', 'wt').write('foo')
135
self.runbzr('add hello')
136
self.runbzr('commit -m setup hello')
138
file('goodbye', 'wt').write('baz')
139
self.runbzr('add goodbye')
140
self.runbzr('commit -m setup goodbye')
142
file('hello', 'wt').write('bar')
143
file('goodbye', 'wt').write('qux')
144
self.runbzr('revert hello')
145
self.check_file_contents('hello', 'foo')
146
self.check_file_contents('goodbye', 'qux')
147
self.runbzr('revert')
148
self.check_file_contents('goodbye', 'baz')
150
os.mkdir('revertdir')
151
self.runbzr('add revertdir')
152
self.runbzr('commit -m f')
153
os.rmdir('revertdir')
154
self.runbzr('revert')
157
def skipped_test_mv_modes(self):
158
"""Test two modes of operation for mv"""
159
from bzrlib.branch import Branch
160
b = Branch('.', init=True)
161
self.build_tree(['a', 'c', 'subdir/'])
162
self.run_bzr('mv', 'a', 'b')
163
self.run_bzr('mv', 'b', 'subdir')
164
self.run_bzr('mv', 'subdir/b', 'a')
165
self.run_bzr('mv', 'a', 'b', 'subdir')
166
self.run_bzr('mv', 'subdir/a', 'subdir/newa')
168
def test_main_version(self):
169
"""Check output from version command and master option is reasonable"""
170
# output is intentionally passed through to stdout so that we
171
# can see the version being tested
172
output = self.runbzr('version', backtick=1)
173
self.log('bzr version output:')
175
self.assert_(output.startswith('bzr (bazaar-ng) '))
176
self.assertNotEqual(output.index('Canonical'), -1)
177
# make sure --version is consistent
178
tmp_output = self.runbzr('--version', backtick=1)
179
self.log('bzr --version output:')
181
self.assertEquals(output, tmp_output)
199
183
class OldTests(ExternalBase):
200
184
# old tests moved from ./testbzr
202
186
from os import chdir, mkdir
203
187
from os.path import exists
365
349
runbzr('log --forward')
374
class RevertCommand(ExternalBase):
379
file('hello', 'wt').write('foo')
380
self.runbzr('add hello')
381
self.runbzr('commit -m setup hello')
383
file('goodbye', 'wt').write('baz')
384
self.runbzr('add goodbye')
385
self.runbzr('commit -m setup goodbye')
387
file('hello', 'wt').write('bar')
388
file('goodbye', 'wt').write('qux')
389
self.runbzr('revert hello')
390
self.check_file_contents('hello', 'foo')
391
self.check_file_contents('goodbye', 'qux')
392
self.runbzr('revert')
393
self.check_file_contents('goodbye', 'baz')
394
os.mkdir('revertdir')
395
self.runbzr('add revertdir')
396
self.runbzr('commit -m f')
397
os.rmdir('revertdir')
398
self.runbzr('revert')