[MERGE] Make some tests use test suite transport rather than local
Andrew Bennetts
andrew at canonical.com
Wed Aug 9 06:04:55 BST 2006
This small patch changes a couple of tests in test_bzrdir to use the test
suite's transport, rather than unconditionally using a local transport. If the
test cannot run non-locally, it raises TestSkipped.
It also updates some old BzrDir formats to create working tree inventory even
when initialising remotely, because otherwise the BzrDir is structurally
incomplete.
I bumped into this because when developing the smart server tests must use the
smart server transport to create their bzrdir. It seems like a worthwhile
change for its own sake. I suspect I'll encounter more tests that need similar
tweaks, but I'd like to get approval for the basic idea before going too far.
-Andrew.
-------------- next part --------------
=== modified file 'bzrlib/bzrdir.py'
--- bzrlib/bzrdir.py 2006-08-07 23:14:45 +0000
+++ bzrlib/bzrdir.py 2006-08-09 04:48:59 +0000
@@ -1217,8 +1217,13 @@
result = (super(BzrDirFormat5, self).initialize_on_transport(transport))
RepositoryFormat5().initialize(result, _internal=True)
if not _cloning:
- BzrBranchFormat4().initialize(result)
- WorkingTreeFormat2().initialize(result)
+ branch = BzrBranchFormat4().initialize(result)
+ try:
+ WorkingTreeFormat2().initialize(result)
+ except errors.NotLocalUrl:
+ # Even though we can't access the working tree, we need to
+ # create its control files.
+ WorkingTreeFormat2().stub_initialize_remote(branch.control_files)
return result
def _open(self, transport):
@@ -1271,13 +1276,13 @@
result = super(BzrDirFormat6, self).initialize_on_transport(transport)
RepositoryFormat6().initialize(result, _internal=True)
if not _cloning:
- BzrBranchFormat4().initialize(result)
+ branch = BzrBranchFormat4().initialize(result)
try:
WorkingTreeFormat2().initialize(result)
except errors.NotLocalUrl:
- # emulate pre-check behaviour for working tree and silently
- # fail.
- pass
+ # Even though we can't access the working tree, we need to
+ # create its control files.
+ WorkingTreeFormat2().stub_initialize_remote(branch.control_files)
return result
def _open(self, transport):
=== modified file 'bzrlib/tests/bzrdir_implementations/test_bzrdir.py'
--- bzrlib/tests/bzrdir_implementations/test_bzrdir.py 2006-08-08 04:54:18 +0000
+++ bzrlib/tests/bzrdir_implementations/test_bzrdir.py 2006-08-09 04:54:41 +0000
@@ -938,24 +938,33 @@
return
# this has to be tested with local access as we still support creating
# format 6 bzrdirs
- t = get_transport('.')
- made_control = self.bzrdir_format.initialize(t.base)
- made_repo = made_control.create_repository()
- made_branch = made_control.create_branch()
- made_tree = made_control.create_workingtree()
+ t = self.get_transport()
+ try:
+ made_control = self.bzrdir_format.initialize(t.base)
+ made_repo = made_control.create_repository()
+ made_branch = made_control.create_branch()
+ made_tree = made_control.create_workingtree()
+ except errors.NotLocalUrl:
+ raise TestSkipped("Can't initialize %r on transport %r"
+ % (self.bzrdir_format, t))
self.failUnless(isinstance(made_tree, workingtree.WorkingTree))
self.assertEqual(made_control, made_tree.bzrdir)
def test_create_workingtree_revision(self):
# a bzrdir can construct a working tree for itself @ a specific revision.
+ t = self.get_transport()
source = self.make_branch_and_tree('source')
source.commit('a', rev_id='a', allow_pointless=True)
source.commit('b', rev_id='b', allow_pointless=True)
self.build_tree(['new/'])
- made_control = self.bzrdir_format.initialize('new')
+ t_new = t.clone('new')
+ made_control = self.bzrdir_format.initialize_on_transport(t_new)
source.branch.repository.clone(made_control)
source.branch.clone(made_control)
- made_tree = made_control.create_workingtree(revision_id='a')
+ try:
+ made_tree = made_control.create_workingtree(revision_id='a')
+ except errors.NotLocalUrl:
+ raise TestSkipped("Can't make working tree on transport %r" % t)
self.assertEqual('a', made_tree.last_revision())
def test_open_workingtree(self):
More information about the bazaar
mailing list