~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_workingtree.py

  • Committer: Jelmer Vernooij
  • Date: 2012-02-20 12:19:29 UTC
  • mfrom: (6437.23.11 2.5)
  • mto: (6581.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6582.
  • Revision ID: jelmer@samba.org-20120220121929-7ni2psvjoatm1yp4
Merge bzr/2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
            workingtree.format_registry.set_default(old_format)
80
80
        self.assertEqual(old_format, workingtree.format_registry.get_default())
81
81
 
 
82
    def test_from_string(self):
 
83
        self.assertIsInstance(
 
84
            SampleTreeFormat.from_string("Sample tree format."),
 
85
            SampleTreeFormat)
 
86
        self.assertRaises(AssertionError,
 
87
            SampleTreeFormat.from_string, "Different format string.")
 
88
 
82
89
    def test_get_set_default_format_by_key(self):
83
90
        old_format = workingtree.format_registry.get_default()
84
91
        # default is 6
120
127
        self.assertEqual('subdir', relpath)
121
128
 
122
129
 
123
 
class SampleTreeFormat(workingtree.WorkingTreeFormat):
 
130
class SampleTreeFormat(workingtree.WorkingTreeFormatMetaDir):
124
131
    """A sample format
125
132
 
126
133
    this format is initializable, unsupported to aid in testing the
127
134
    open and open_downlevel routines.
128
135
    """
129
136
 
130
 
    def get_format_string(self):
 
137
    @classmethod
 
138
    def get_format_string(cls):
131
139
        """See WorkingTreeFormat.get_format_string()."""
132
140
        return "Sample tree format."
133
141
 
172
180
        # is the right format object found for a working tree?
173
181
        branch = self.make_branch('branch')
174
182
        self.assertRaises(errors.NoWorkingTree,
175
 
            workingtree.WorkingTreeFormat.find_format_string, branch.bzrdir)
 
183
            workingtree.WorkingTreeFormatMetaDir.find_format_string, branch.bzrdir)
176
184
        transport = branch.bzrdir.get_workingtree_transport(None)
177
185
        transport.mkdir('.')
178
186
        transport.put_bytes("format", "some format name")
179
187
        # The format does not have to be known by Bazaar,
180
188
        # find_format_string just retrieves the name
181
189
        self.assertEquals("some format name",
182
 
            workingtree.WorkingTreeFormat.find_format_string(branch.bzrdir))
 
190
            workingtree.WorkingTreeFormatMetaDir.find_format_string(branch.bzrdir))
183
191
 
184
192
    def test_find_format(self):
185
193
        # is the right format object found for a working tree?
191
199
            dir.create_branch()
192
200
            format.initialize(dir)
193
201
            t = transport.get_transport(url)
194
 
            found_format = workingtree.WorkingTreeFormat.find_format(dir)
 
202
            found_format = workingtree.WorkingTreeFormatMetaDir.find_format(dir)
195
203
            self.assertIsInstance(found_format, format.__class__)
196
204
        check_format(workingtree_3.WorkingTreeFormat3(), "bar")
197
205
 
198
206
    def test_find_format_no_tree(self):
199
207
        dir = bzrdir.BzrDirMetaFormat1().initialize('.')
200
208
        self.assertRaises(errors.NoWorkingTree,
201
 
                          workingtree.WorkingTreeFormat.find_format,
 
209
                          workingtree.WorkingTreeFormatMetaDir.find_format,
202
210
                          dir)
203
211
 
204
212
    def test_find_format_unknown_format(self):
207
215
        dir.create_branch()
208
216
        SampleTreeFormat().initialize(dir)
209
217
        self.assertRaises(errors.UnknownFormatError,
210
 
                          workingtree.WorkingTreeFormat.find_format,
 
218
                          workingtree.WorkingTreeFormatMetaDir.find_format,
211
219
                          dir)
212
220
 
213
221
    def test_register_unregister_format(self):
235
243
            self.applyDeprecated(symbol_versioning.deprecated_in((2, 4, 0)),
236
244
                workingtree.WorkingTreeFormat.get_formats))
237
245
 
 
246
    def test_find_format_with_features(self):
 
247
        tree = self.make_branch_and_tree('.', format='2a')
 
248
        tree.update_feature_flags({"name": "necessity"})
 
249
        found_format = workingtree.WorkingTreeFormatMetaDir.find_format(
 
250
            tree.bzrdir)
 
251
        self.assertIsInstance(found_format, workingtree.WorkingTreeFormat)
 
252
        self.assertEquals(found_format.features.get("name"), "necessity")
 
253
        self.assertRaises(errors.MissingFeature, found_format.check_support_status,
 
254
            True)
 
255
        self.addCleanup(workingtree.WorkingTreeFormatMetaDir.unregister_feature,
 
256
            "name")
 
257
        workingtree.WorkingTreeFormatMetaDir.register_feature("name")
 
258
        found_format.check_support_status(True)
 
259
 
238
260
 
239
261
class TestWorkingTreeIterEntriesByDir_wSubtrees(TestCaseWithTransport):
240
262