~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

(robertc) Introduce Tree interface implementation tests. This corrects behaviour differences in Tree implementations for the __iter__ interface which were revealed by the new tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
459
459
    def get_file(self, file_id):
460
460
        return self.get_file_byname(self.id2path(file_id))
461
461
 
 
462
    def get_file_text(self, file_id):
 
463
        return self.get_file(file_id).read()
 
464
 
462
465
    def get_file_byname(self, filename):
463
466
        return file(self.abspath(filename), 'rb')
464
467
 
1858
1861
        self._transport_readonly_server = transport_readonly_server
1859
1862
        self._formats = formats
1860
1863
    
 
1864
    def _clone_test(self, test, bzrdir_format, workingtree_format, variation):
 
1865
        """Clone test for adaption."""
 
1866
        new_test = deepcopy(test)
 
1867
        new_test.transport_server = self._transport_server
 
1868
        new_test.transport_readonly_server = self._transport_readonly_server
 
1869
        new_test.bzrdir_format = bzrdir_format
 
1870
        new_test.workingtree_format = workingtree_format
 
1871
        def make_new_test_id():
 
1872
            new_id = "%s(%s)" % (test.id(), variation)
 
1873
            return lambda: new_id
 
1874
        new_test.id = make_new_test_id()
 
1875
        return new_test
 
1876
    
1861
1877
    def adapt(self, test):
1862
1878
        from bzrlib.tests import TestSuite
1863
1879
        result = TestSuite()
1864
1880
        for workingtree_format, bzrdir_format in self._formats:
1865
 
            new_test = deepcopy(test)
1866
 
            new_test.transport_server = self._transport_server
1867
 
            new_test.transport_readonly_server = self._transport_readonly_server
1868
 
            new_test.bzrdir_format = bzrdir_format
1869
 
            new_test.workingtree_format = workingtree_format
1870
 
            def make_new_test_id():
1871
 
                new_id = "%s(%s)" % (new_test.id(), workingtree_format.__class__.__name__)
1872
 
                return lambda: new_id
1873
 
            new_test.id = make_new_test_id()
 
1881
            new_test = self._clone_test(
 
1882
                test,
 
1883
                bzrdir_format,
 
1884
                workingtree_format, workingtree_format.__class__.__name__)
1874
1885
            result.addTest(new_test)
1875
1886
        return result