/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_workingtree.py

  • Committer: Jelmer Vernooij
  • Date: 2011-05-04 20:03:08 UTC
  • mfrom: (5824 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5828.
  • Revision ID: jelmer@samba.org-20110504200308-7dzetv0igs4gh5p2
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
            workingtree.format_registry.set_default(old_format)
78
78
        self.assertEqual(old_format, workingtree.format_registry.get_default())
79
79
 
 
80
    def test_get_set_default_format_by_key(self):
 
81
        old_format = workingtree.format_registry.get_default()
 
82
        # default is 3
 
83
        format = SampleTreeFormat()
 
84
        workingtree.format_registry.register(format)
 
85
        self.addCleanup(workingtree.format_registry.remove, format)
 
86
        self.assertTrue(isinstance(old_format, workingtree.WorkingTreeFormat3))
 
87
        workingtree.format_registry.set_default_key(format.get_format_string())
 
88
        try:
 
89
            # the default branch format is used by the meta dir format
 
90
            # which is not the default bzrdir format at this point
 
91
            dir = bzrdir.BzrDirMetaFormat1().initialize('.')
 
92
            dir.create_repository()
 
93
            dir.create_branch()
 
94
            result = dir.create_workingtree()
 
95
            self.assertEqual(result, 'A tree')
 
96
        finally:
 
97
            workingtree.format_registry.set_default_key(
 
98
                old_format.get_format_string())
 
99
        self.assertEqual(old_format, workingtree.format_registry.get_default())
 
100
 
80
101
    def test_open(self):
81
102
        tree = self.make_branch_and_tree('.')
82
103
        open_direct = workingtree.WorkingTree.open('.')
145
166
class TestWorkingTreeFormat(TestCaseWithTransport):
146
167
    """Tests for the WorkingTreeFormat facility."""
147
168
 
 
169
    def test_find_format_string(self):
 
170
        # is the right format object found for a working tree?
 
171
        branch = self.make_branch('branch')
 
172
        self.assertRaises(errors.NoWorkingTree,
 
173
            workingtree.WorkingTreeFormat.find_format_string, branch.bzrdir)
 
174
        transport = branch.bzrdir.get_workingtree_transport(None)
 
175
        transport.mkdir('.')
 
176
        transport.put_bytes("format", "some format name")
 
177
        # The format does not have to be known by Bazaar,
 
178
        # find_format_string just retrieves the name
 
179
        self.assertEquals("some format name",
 
180
            workingtree.WorkingTreeFormat.find_format_string(branch.bzrdir))
 
181
 
148
182
    def test_find_format(self):
149
183
        # is the right format object found for a working tree?
150
184
        # create a branch with a few known format objects.