~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_workingtree.py

Merge pt1 hooks branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
123
123
        return "opened tree."
124
124
 
125
125
 
 
126
class SampleExtraTreeFormat(workingtree.WorkingTreeFormat):
 
127
    """A sample format that does not support use in a metadir.
 
128
 
 
129
    """
 
130
 
 
131
    def get_format_string(self):
 
132
        # Not usable in a metadir, so no format string
 
133
        return None
 
134
 
 
135
    def initialize(self, a_bzrdir, revision_id=None, from_branch=None,
 
136
                   accelerator_tree=None, hardlink=False):
 
137
        raise NotImplementedError(self.initialize)
 
138
 
 
139
    def is_supported(self):
 
140
        return False
 
141
 
 
142
    def open(self, transport, _found=False):
 
143
        raise NotImplementedError(self.open)
 
144
 
 
145
 
126
146
class TestWorkingTreeFormat(TestCaseWithTransport):
127
147
    """Tests for the WorkingTreeFormat facility."""
128
148
 
165
185
        format.initialize(dir)
166
186
        # register a format for it.
167
187
        workingtree.WorkingTreeFormat.register_format(format)
 
188
        self.assertTrue(format in workingtree.WorkingTreeFormat.get_formats())
168
189
        # which branch.Open will refuse (not supported)
169
190
        self.assertRaises(errors.UnsupportedFormatError, workingtree.WorkingTree.open, '.')
170
191
        # but open_downlevel will work
171
192
        self.assertEqual(format.open(dir), workingtree.WorkingTree.open_downlevel('.'))
172
193
        # unregister the format
173
194
        workingtree.WorkingTreeFormat.unregister_format(format)
 
195
        self.assertFalse(format in workingtree.WorkingTreeFormat.get_formats())
 
196
 
 
197
    def test_register_unregister_extra_format(self):
 
198
        format = SampleExtraTreeFormat()
 
199
        workingtree.WorkingTreeFormat.register_extra_format(format)
 
200
        self.assertTrue(format in workingtree.WorkingTreeFormat.get_formats())
 
201
        workingtree.WorkingTreeFormat.unregister_extra_format(format)
 
202
        self.assertFalse(format in workingtree.WorkingTreeFormat.get_formats())
174
203
 
175
204
 
176
205
class TestWorkingTreeFormat3(TestCaseWithTransport):