~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_tree/test_tree.py

  • Committer: Samuel Bronson
  • Date: 2012-08-30 20:36:18 UTC
  • mto: (6015.57.3 2.4)
  • mto: This revision was merged to the branch mainline in revision 6558.
  • Revision ID: naesten@gmail.com-20120830203618-y2dzw91nqpvpgxvx
Update INSTALL for switch to Python 2.6 and up.

Show diffs side-by-side

added added

removed removed

Lines of Context:
158
158
        work_tree = self.make_branch_and_tree('wt')
159
159
        tree = self.get_tree_no_parents_abc_content_2(work_tree)
160
160
        tree.lock_read()
161
 
        self.addCleanup(tree.unlock)
162
 
        # Test lookup without path works
163
 
        file_without_path = tree.get_file('a-id')
164
 
        try:
165
 
            lines = file_without_path.readlines()
166
 
            self.assertEqual(['foobar\n'], lines)
167
 
        finally:
168
 
            file_without_path.close()
169
 
        # Test lookup with path works
170
 
        file_with_path = tree.get_file('a-id', path='a')
171
 
        try:
172
 
            lines = file_with_path.readlines()
173
 
            self.assertEqual(['foobar\n'], lines)
174
 
        finally:
175
 
            file_with_path.close()
 
161
        try:
 
162
            # Test lookup without path works
 
163
            lines = tree.get_file('a-id').readlines()
 
164
            self.assertEqual(['foobar\n'], lines)
 
165
            # Test lookup with path works
 
166
            lines = tree.get_file('a-id', path='a').readlines()
 
167
            self.assertEqual(['foobar\n'], lines)
 
168
        finally:
 
169
            tree.unlock()
176
170
 
177
171
    def test_get_file_text(self):
178
172
        work_tree = self.make_branch_and_tree('wt')
309
303
        self.addCleanup(tree.unlock)
310
304
        expected = osutils.sha_strings('file content')
311
305
        self.assertEqual(expected, tree.get_file_sha1('file-id'))
312
 
 
313
 
 
314
 
class TestGetFileVerifier(TestCaseWithTree):
315
 
 
316
 
    def test_get_file_verifier(self):
317
 
        work_tree = self.make_branch_and_tree('tree')
318
 
        self.build_tree_contents([
319
 
            ('tree/file1', 'file content'),
320
 
            ('tree/file2', 'file content')])
321
 
        work_tree.add(['file1', 'file2'], ['file-id-1', 'file-id-2'])
322
 
        tree = self._convert_tree(work_tree)
323
 
        tree.lock_read()
324
 
        self.addCleanup(tree.unlock)
325
 
        (kind, data) = tree.get_file_verifier('file-id-1')
326
 
        self.assertEquals(
327
 
            tree.get_file_verifier('file-id-1'),
328
 
            tree.get_file_verifier('file-id-2'))
329
 
        if kind == "SHA1":
330
 
            expected = osutils.sha_strings('file content')
331
 
            self.assertEqual(expected, data)
332
 
 
333
 
 
334
 
class TestHasVersionedDirectories(TestCaseWithTree):
335
 
 
336
 
    def test_has_versioned_directories(self):
337
 
        work_tree = self.make_branch_and_tree('tree')
338
 
        tree = self._convert_tree(work_tree)
339
 
        self.assertSubset([tree.has_versioned_directories()], (True, False))