~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_testament.py

Move doctest import to increase speed

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
from bzrlib.tests import TestCaseWithTransport
26
26
from bzrlib.branch import Branch
27
 
from bzrlib.testament import Testament, StrictTestament
 
27
from bzrlib.testament import Testament
28
28
from bzrlib.trace import mutter
29
 
from bzrlib.transform import TreeTransform
30
29
from bzrlib.osutils import has_symlinks
31
30
 
32
31
 
47
46
                             ('src/foo.c', 'int main()\n{\n}\n')])
48
47
        self.wt.add(['hello', 'src', 'src/foo.c'],
49
48
                             ['hello-id', 'src-id', 'foo.c-id'])
50
 
        tt = TreeTransform(self.wt)
51
 
        trans_id = tt.trans_id_tree_path('hello')
52
 
        tt.set_executability(True, trans_id)
53
 
        tt.apply()
54
49
        self.wt.commit(message='add files and directories',
55
50
                 timestamp=1129025483,
56
51
                 timezone=36000,
75
70
        self.log('testament text form:\n' + text_form)
76
71
        self.assertEqual(text_form, REV_1_TESTAMENT)
77
72
 
78
 
    def test_strict_testment_text_form(self):
79
 
        """Conversion of testament to canonical text form."""
80
 
        t = StrictTestament.from_revision(self.b.repository, 'test@user-1')
81
 
        text_form = t.as_text()
82
 
        self.log('testament text form:\n' + text_form)
83
 
        self.assertEqualDiff(text_form, REV_1_STRICT_TESTAMENT)
84
 
 
85
73
    def test_testament_with_contents(self):
86
74
        """Testament containing a file and a directory."""
87
75
        t = Testament.from_revision(self.b.repository, 'test@user-2')
91
79
        actual_short = t.as_short_text()
92
80
        self.assertEqualDiff(actual_short, REV_2_SHORT)
93
81
 
94
 
    def test_strict_testament_with_contents(self):
95
 
        """Testament containing a file and a directory."""
96
 
        t = StrictTestament.from_revision(self.b.repository, 'test@user-2')
97
 
        text_form = t.as_text()
98
 
        self.log('testament text form:\n' + text_form)
99
 
        self.assertEqualDiff(text_form, REV_2_STRICT_TESTAMENT)
100
 
        actual_short = t.as_short_text()
101
 
        self.assertEqualDiff(actual_short, REV_2_SHORT_STRICT)
102
 
 
103
82
    def test_testament_command(self):
104
83
        """Testament containing a file and a directory."""
105
84
        out, err = self.run_bzr_captured(['testament', '--long'])
112
91
        self.assertEqualDiff(err, '')
113
92
        self.assertEqualDiff(out, REV_1_SHORT)
114
93
 
115
 
    def test_testament_command_3(self):
116
 
        """Command getting short testament of previous version."""
117
 
        out, err = self.run_bzr_captured(['testament', '-r1', '--strict'])
118
 
        self.assertEqualDiff(err, '')
119
 
        self.assertEqualDiff(out, REV_1_SHORT_STRICT)
120
 
 
121
94
    def test_testament_symlinks(self):
122
95
        """Testament containing symlink (where possible)"""
123
96
        if not has_symlinks():
180
153
    test branch
181
154
"""
182
155
 
183
 
REV_1_STRICT_TESTAMENT = """\
184
 
bazaar-ng testament version 2.1
185
 
revision-id: test@user-1
186
 
committer: test@user
187
 
timestamp: 1129025423
188
 
timezone: 0
189
 
parents:
190
 
message:
191
 
  initial null commit
192
 
inventory:
193
 
properties:
194
 
  branch-nick:
195
 
    test branch
196
 
"""
197
 
 
198
 
 
199
156
REV_1_SHORT = """\
200
157
bazaar-ng testament short form 1
201
158
revision-id: test@user-1
203
160
""" % sha(REV_1_TESTAMENT).hexdigest()
204
161
 
205
162
 
206
 
REV_1_SHORT_STRICT = """\
207
 
bazaar-ng testament short form 2.1
208
 
revision-id: test@user-1
209
 
sha1: %s
210
 
""" % sha(REV_1_STRICT_TESTAMENT).hexdigest()
211
 
 
212
 
 
213
163
REV_2_TESTAMENT = """\
214
164
bazaar-ng testament version 1
215
165
revision-id: test@user-2
230
180
"""
231
181
 
232
182
 
233
 
REV_2_STRICT_TESTAMENT = """\
234
 
bazaar-ng testament version 2.1
235
 
revision-id: test@user-2
236
 
committer: test@user
237
 
timestamp: 1129025483
238
 
timezone: 36000
239
 
parents:
240
 
  test@user-1
241
 
message:
242
 
  add files and directories
243
 
inventory:
244
 
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
245
 
  directory src src-id test@user-2 no
246
 
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
247
 
properties:
248
 
  branch-nick:
249
 
    test branch
250
 
"""
251
 
 
252
 
 
253
183
REV_2_SHORT = """\
254
184
bazaar-ng testament short form 1
255
185
revision-id: test@user-2
257
187
""" % sha(REV_2_TESTAMENT).hexdigest()
258
188
 
259
189
 
260
 
REV_2_SHORT_STRICT = """\
261
 
bazaar-ng testament short form 2.1
262
 
revision-id: test@user-2
263
 
sha1: %s
264
 
""" % sha(REV_2_STRICT_TESTAMENT).hexdigest()
265
 
 
266
 
 
267
190
REV_PROPS_TESTAMENT = """\
268
191
bazaar-ng testament version 1
269
192
revision-id: test@user-3