1
"""Black-box tests for default log_formats/log_formatters
6
from bzrlib.branch import Branch
7
from bzrlib.tests import TestCaseInTempDir
8
from bzrlib.config import (config_dir, config_filename)
11
class TestLogFormats(TestCaseInTempDir):
13
def bzr(self, *args, **kwargs):
14
return self.run_bzr(*args, **kwargs)[0]
16
def test_log_default_format(self):
20
open('a', 'wb').write('foo\n')
23
self.bzr('commit', '-m', '1')
24
open('a', 'wb').write('baz\n')
26
self.bzr('commit', '-m', '2')
28
# only the lines formatter is this short
29
self.assertEquals(3, len(self.bzr('log').split('\n')))
31
def test_log_format_arg(self):
33
open('a', 'wb').write('foo\n')
36
self.bzr('commit', '-m', '1')
37
open('a', 'wb').write('baz\n')
39
self.bzr('commit', '-m', '2')
41
# only the lines formatter is this short
42
self.assertEquals(7, len(self.bzr('log', '--log-format', 'short').split('\n')))
44
def test_missing_default_format(self):
51
open('a', 'wb').write('foo\n')
53
self.bzr('commit', '-m', '1')
56
self.bzr('branch', 'a', 'b')
59
open('a', 'wb').write('bar\n')
60
self.bzr('commit', '-m', '2')
62
open('a', 'wb').write('baz\n')
63
self.bzr('commit', '-m', '3')
67
self.assertEquals(5, len(self.bzr('missing', retcode=1).split('\n')))
71
def test_missing_format_arg(self):
78
open('a', 'wb').write('foo\n')
80
self.bzr('commit', '-m', '1')
83
self.bzr('branch', 'a', 'b')
86
open('a', 'wb').write('bar\n')
87
self.bzr('commit', '-m', '2')
89
open('a', 'wb').write('baz\n')
90
self.bzr('commit', '-m', '3')
94
self.assertEquals(9, len(self.bzr('missing', '--log-format', 'short', retcode=1).split('\n')))
100
if os.path.isfile(config_filename()):
101
# Something is wrong in environment,
102
# we risk overwriting users config
103
self.assert_(config_filename() + "exists, abort")
105
os.mkdir(config_dir())
106
CONFIG=("[DEFAULT]\n"
107
"email=Joe Foo <joe@foo.com>\n"
110
open(config_filename(),'wb').write(CONFIG)