86
87
os.remove('branch/c')
89
def test_no_working_tree(self):
90
tree = self.create_tree()
91
branch = self.make_branch('just_branch')
92
branch.pull(tree.branch)
94
txt = self.run_bzr('version-info', 'just_branch')[0]
95
self.assertStartsWith(txt, 'revision-id: r2\n')
97
def assertEqualNoBuildDate(self, text1, text2):
98
"""Compare 2 texts, but ignore the build-date field.
100
build-date is the current timestamp, accurate to seconds. But the
101
clock is always ticking, and it may have ticked between the time
102
that text1 and text2 were generated.
104
lines1 = text1.splitlines(True)
105
lines2 = text2.splitlines(True)
106
for line1, line2 in zip(lines1, lines2):
107
if line1.startswith('build-date: '):
108
self.assertStartsWith(line2, 'build-date: ')
110
self.assertEqual(line1, line2)
111
self.assertEqual(len(lines1), len(lines2))
88
113
def test_no_branch(self):
89
114
"""Test that bzr defaults to the local working directory"""
92
117
txt1 = self.run_bzr('version-info', 'branch')[0]
94
119
os.chdir('branch')
95
120
txt2 = self.run_bzr('version-info')[0]
96
self.assertEqual(txt1, txt2)
121
self.assertEqualNoBuildDate(txt1, txt2)
98
123
def test_rio(self):
99
124
"""Test that we can pass --format=rio"""
102
127
txt = self.run_bzr('version-info', 'branch')[0]
103
128
txt1 = self.run_bzr('version-info', '--format', 'rio', 'branch')[0]
104
129
txt2 = self.run_bzr('version-info', '--format=rio', 'branch')[0]
105
self.assertEqual(txt, txt1)
106
self.assertEqual(txt, txt2)
130
self.assertEqualNoBuildDate(txt, txt1)
131
self.assertEqualNoBuildDate(txt, txt2)
108
133
def test_python(self):
109
134
"""Test that we can do --format=python"""
112
137
txt = self.run_bzr('version-info', '--format', 'python', 'branch')[0]