/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_bzrdir.py

  • Committer: Vincent Ladeuil
  • Date: 2010-01-25 15:55:48 UTC
  • mto: (4985.1.4 add-attr-cleanup)
  • mto: This revision was merged to the branch mainline in revision 4988.
  • Revision ID: v.ladeuil+lp@free.fr-20100125155548-0l352pujvt5bzl5e
Deploy addAttrCleanup on the whole test suite.

Several use case worth mentioning:

- setting a module or any other object attribute is the majority
by far. In some cases the setting itself is deferred but most of
the time we want to set at the same time we add the cleanup.

- there multiple occurrences of protecting hooks or ui factory
which are now useless (the test framework takes care of that now),

- there was some lambda uses that can now be avoided.

That first cleanup already simplifies things a lot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
36
36
    )
37
37
import bzrlib.branch
38
38
from bzrlib.errors import (NotBranchError,
39
 
                           NoColocatedBranchSupport,
40
39
                           UnknownFormatError,
41
40
                           UnsupportedFormatError,
42
41
                           )
51
50
    http_utils,
52
51
    )
53
52
from bzrlib.tests.test_http import TestWithTransport_pycurl
54
 
from bzrlib.transport import (
55
 
    get_transport,
56
 
    memory,
57
 
    )
 
53
from bzrlib.transport import get_transport
58
54
from bzrlib.transport.http._urllib import HttpTransport_urllib
 
55
from bzrlib.transport.memory import MemoryServer
59
56
from bzrlib.transport.nosmart import NoSmartTransportDecorator
60
57
from bzrlib.transport.readonly import ReadonlyTransportDecorator
61
58
from bzrlib.repofmt import knitrepo, weaverepo, pack_repo
207
204
        """See BzrDir.open_repository."""
208
205
        return SampleRepository(self)
209
206
 
210
 
    def create_branch(self, name=None):
 
207
    def create_branch(self):
211
208
        """See BzrDir.create_branch."""
212
 
        if name is not None:
213
 
            raise NoColocatedBranchSupport(self)
214
209
        return SampleBranch(self)
215
210
 
216
211
    def create_workingtree(self):
359
354
 
360
355
    def test_create_branch_convenience_root(self):
361
356
        """Creating a branch at the root of a fs should work."""
362
 
        self.vfs_transport_factory = memory.MemoryServer
 
357
        self.vfs_transport_factory = MemoryServer
363
358
        # outside a repo the default convenience output is a repo+branch_tree
364
359
        format = bzrdir.format_registry.make_bzrdir('knit')
365
360
        branch = bzrdir.BzrDir.create_branch_convenience(self.get_url(),
471
466
        # Make stackable source branch with an unstackable repo format.
472
467
        source_bzrdir = self.make_bzrdir('source')
473
468
        pack_repo.RepositoryFormatKnitPack1().initialize(source_bzrdir)
474
 
        source_branch = bzrlib.branch.BzrBranchFormat7().initialize(
475
 
            source_bzrdir)
 
469
        source_branch = bzrlib.branch.BzrBranchFormat7().initialize(source_bzrdir)
476
470
        # Make a directory with a default stacking policy
477
471
        parent_bzrdir = self.make_bzrdir('parent')
478
472
        stacked_on = self.make_branch('parent/stacked-on', format='pack-0.92')
571
565
 
572
566
    def setUp(self):
573
567
        super(ChrootedTests, self).setUp()
574
 
        if not self.vfs_transport_factory == memory.MemoryServer:
 
568
        if not self.vfs_transport_factory == MemoryServer:
575
569
            self.transport_readonly_server = http_server.HttpServer
576
570
 
577
571
    def local_branch_path(self, branch):
1055
1049
 
1056
1050
    def setUp(self):
1057
1051
        super(NonLocalTests, self).setUp()
1058
 
        self.vfs_transport_factory = memory.MemoryServer
 
1052
        self.vfs_transport_factory = MemoryServer
1059
1053
 
1060
1054
    def test_create_branch_convenience(self):
1061
1055
        # outside a repo the default convenience output is a repo+branch_tree
1339
1333
        url = transport.base
1340
1334
        err = self.assertRaises(errors.BzrError, bzrdir.BzrDir.open, url)
1341
1335
        self.assertEqual('fail', err._preformatted_string)
1342
 
 
1343
 
    def test_post_repo_init(self):
1344
 
        from bzrlib.bzrdir import RepoInitHookParams
1345
 
        calls = []
1346
 
        bzrdir.BzrDir.hooks.install_named_hook('post_repo_init',
1347
 
            calls.append, None)
1348
 
        self.make_repository('foo')
1349
 
        self.assertLength(1, calls)
1350
 
        params = calls[0]
1351
 
        self.assertIsInstance(params, RepoInitHookParams)
1352
 
        self.assertTrue(hasattr(params, 'bzrdir'))
1353
 
        self.assertTrue(hasattr(params, 'repository'))