1
"""Black-box tests for bzr aliases.
6
from bzrlib.branch import Branch
7
from bzrlib.tests import TestCaseInTempDir
8
from bzrlib.trace import mutter
9
from bzrlib.config import (config_dir, config_filename)
12
class TestAliases(TestCaseInTempDir):
14
def test_aliases(self):
16
def bzr(*args, **kwargs):
17
return self.run_bzr(*args, **kwargs)[0]
19
def bzr_catch_error(*args, **kwargs):
20
return self.run_bzr(*args, **kwargs)[1]
23
if os.path.isfile(config_filename()):
24
# Something is wrong in environment,
25
# we risk overwriting users config
26
self.assert_(config_filename() + "exists, abort")
28
os.mkdir(config_dir())
34
open(config_filename(),'wb').write(CONFIG)
41
open('a', 'wb').write(str1)
44
bzr('commit', '-m', '1')
46
self.assertEquals(bzr('c', 'a'), str1)
48
open('a', 'wb').write(str2)
49
bzr('commit', '-m', '2')
51
self.assertEquals(bzr('c', 'a'), str2)
52
self.assertEquals(bzr('c1', 'a'), str1)
53
self.assertEquals(bzr('c1', '--revision', '2', 'a'), str2)
55
# If --no-aliases isn't working, we will not get retcode=3
56
bzr('--no-aliases', 'c', 'a', retcode=3)
58
# If --no-aliases breaks all of bzr, we also get retcode=3
59
# So we need to catch the output as well
60
self.assertEquals(bzr_catch_error('--no-aliases', 'c', 'a',
62
"bzr: ERROR: unknown command 'c'\n")
64
bzr('c', '-r1', '-r2', retcode=3)
65
bzr('c1', '-r1', '-r2', retcode=3)
67
bzr('c2', '-r1', retcode=3)