~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_workingtree.py

  • Committer: Martin Packman
  • Date: 2011-12-08 19:00:14 UTC
  • mto: This revision was merged to the branch mainline in revision 6359.
  • Revision ID: martin.packman@canonical.com-20111208190014-mi8jm6v7jygmhb0r
Use --include-duplicates for make update-pot which already combines multiple msgid strings prettily

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
 
 
89
82
    def test_get_set_default_format_by_key(self):
90
83
        old_format = workingtree.format_registry.get_default()
91
84
        # default is 6
127
120
        self.assertEqual('subdir', relpath)
128
121
 
129
122
 
130
 
class SampleTreeFormat(workingtree.WorkingTreeFormatMetaDir):
 
123
class SampleTreeFormat(workingtree.WorkingTreeFormat):
131
124
    """A sample format
132
125
 
133
126
    this format is initializable, unsupported to aid in testing the
134
127
    open and open_downlevel routines.
135
128
    """
136
129
 
137
 
    @classmethod
138
 
    def get_format_string(cls):
 
130
    def get_format_string(self):
139
131
        """See WorkingTreeFormat.get_format_string()."""
140
132
        return "Sample tree format."
141
133
 
180
172
        # is the right format object found for a working tree?
181
173
        branch = self.make_branch('branch')
182
174
        self.assertRaises(errors.NoWorkingTree,
183
 
            workingtree.WorkingTreeFormatMetaDir.find_format_string, branch.bzrdir)
 
175
            workingtree.WorkingTreeFormat.find_format_string, branch.bzrdir)
184
176
        transport = branch.bzrdir.get_workingtree_transport(None)
185
177
        transport.mkdir('.')
186
178
        transport.put_bytes("format", "some format name")
187
179
        # The format does not have to be known by Bazaar,
188
180
        # find_format_string just retrieves the name
189
181
        self.assertEquals("some format name",
190
 
            workingtree.WorkingTreeFormatMetaDir.find_format_string(branch.bzrdir))
 
182
            workingtree.WorkingTreeFormat.find_format_string(branch.bzrdir))
191
183
 
192
184
    def test_find_format(self):
193
185
        # is the right format object found for a working tree?
199
191
            dir.create_branch()
200
192
            format.initialize(dir)
201
193
            t = transport.get_transport(url)
202
 
            found_format = workingtree.WorkingTreeFormatMetaDir.find_format(dir)
 
194
            found_format = workingtree.WorkingTreeFormat.find_format(dir)
203
195
            self.assertIsInstance(found_format, format.__class__)
204
196
        check_format(workingtree_3.WorkingTreeFormat3(), "bar")
205
197
 
206
198
    def test_find_format_no_tree(self):
207
199
        dir = bzrdir.BzrDirMetaFormat1().initialize('.')
208
200
        self.assertRaises(errors.NoWorkingTree,
209
 
                          workingtree.WorkingTreeFormatMetaDir.find_format,
 
201
                          workingtree.WorkingTreeFormat.find_format,
210
202
                          dir)
211
203
 
212
204
    def test_find_format_unknown_format(self):
215
207
        dir.create_branch()
216
208
        SampleTreeFormat().initialize(dir)
217
209
        self.assertRaises(errors.UnknownFormatError,
218
 
                          workingtree.WorkingTreeFormatMetaDir.find_format,
 
210
                          workingtree.WorkingTreeFormat.find_format,
219
211
                          dir)
220
212
 
221
213
    def test_register_unregister_format(self):
243
235
            self.applyDeprecated(symbol_versioning.deprecated_in((2, 4, 0)),
244
236
                workingtree.WorkingTreeFormat.get_formats))
245
237
 
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
 
 
260
238
 
261
239
class TestWorkingTreeIterEntriesByDir_wSubtrees(TestCaseWithTransport):
262
240