14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
"""Blackbox tests for the 'bzr testament' command"""
20
from bzrlib.tests.test_testament import (
17
"""Blackbox tests for the 'brz testament' command"""
21
from breezy.tests.test_testament import (
22
24
REV_1_SHORT_STRICT,
28
30
class TestTestament(TestamentSetup):
29
"""Run blackbox tests on 'bzr testament'"""
31
"""Run blackbox tests on 'brz testament'"""
31
33
def test_testament_command(self):
32
34
"""Testament containing a file and a directory."""
33
35
out, err = self.run_bzr('testament --long')
34
36
self.assertEqualDiff(err, '')
35
self.assertEqualDiff(out, REV_2_TESTAMENT)
37
self.assertEqualDiff(out, REV_2_TESTAMENT.decode('ascii'))
37
39
def test_testament_command_2(self):
38
40
"""Command getting short testament of previous version."""
39
41
out, err = self.run_bzr('testament -r1')
40
42
self.assertEqualDiff(err, '')
41
self.assertEqualDiff(out, REV_1_SHORT)
43
self.assertEqualDiff(out, REV_1_SHORT.decode('ascii'))
43
45
def test_testament_command_3(self):
44
46
"""Command getting short testament of previous version."""
45
47
out, err = self.run_bzr('testament -r1 --strict')
46
48
self.assertEqualDiff(err, '')
47
self.assertEqualDiff(out, REV_1_SHORT_STRICT)
49
self.assertEqualDiff(out, REV_1_SHORT_STRICT.decode('ascii'))
51
def test_testament_non_ascii(self):
52
self.wt.commit(u"Non \xe5ssci message")
53
long_out, err = self.run_bzr_raw('testament --long', encoding='utf-8')
54
self.assertEqualDiff(err, b'')
55
long_out, err = self.run_bzr_raw('testament --long', encoding='ascii')
56
short_out, err = self.run_bzr_raw('testament', encoding='ascii')
57
self.assertEqualDiff(err, b'')
58
sha1_re = re.compile(b'sha1: (?P<sha1>[a-f0-9]+)$', re.M)
59
sha1 = sha1_re.search(short_out).group('sha1')
60
self.assertEqual(sha1, osutils.sha_string(long_out))