Rev 5805: Remove the duplicated comment so we can make the comment bigger :) in file:///home/vila/src/bzr/experimental/config/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Tue May 31 16:53:17 UTC 2011
At file:///home/vila/src/bzr/experimental/config/
------------------------------------------------------------
revno: 5805
revision-id: v.ladeuil+lp at free.fr-20110531165317-ooq9p17n3xec1akg
parent: v.ladeuil+lp at free.fr-20110531154630-lkmr518bl2ig1mdx
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: config-lock-remote
timestamp: Tue 2011-05-31 18:53:17 +0200
message:
Remove the duplicated comment so we can make the comment bigger :)
-------------- next part --------------
=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py 2011-05-31 15:46:30 +0000
+++ b/bzrlib/tests/test_config.py 2011-05-31 16:53:17 +0000
@@ -104,12 +104,25 @@
test.backing_branch = test.make_branch(relpath)
+def keep_branch_alive(test, b):
+ """Keep a branch alive for the duration of a test.
+
+ :param tests: the test that should hold the branch alive.
+
+ :param b: the branch that should be kept alive.
+
+ Several tests need to keep a reference to a branch object as they are
+ testing a Store which uses a weak reference. This is achieved by embedding
+ a reference to the branch object in a lambda passed to a cleanup. When the
+ test finish the cleanup method is deleted and so does the reference to the
+ branch.
+ """
+ test.addCleanup(lambda : b)
+
def build_branch_store(test):
build_backing_branch(test, 'branch')
b = branch.Branch.open('branch')
- # We need to keep a reference to the branch as the Store uses a weak
- # ref. Referring to it in a lambda should be enough.
- test.addCleanup(lambda : b)
+ keep_branch_alive(test, b)
return config.BranchStore(b)
config.test_store_builder_registry.register('branch', build_branch_store)
@@ -120,9 +133,7 @@
(transport_class, server_class) = remote.get_test_permutations()[0]
build_backing_branch(test, 'branch', transport_class, server_class)
b = branch.Branch.open(test.get_url('branch'))
- # We need to keep a reference to the branch as the Store uses a weak
- # ref. Referring to it in a lambda should be enough.
- test.addCleanup(lambda : b)
+ keep_branch_alive(test, b)
return config.BranchStore(b)
config.test_store_builder_registry.register('remote_branch',
build_remote_branch_store)
@@ -137,9 +148,7 @@
def build_branch_stack(test):
build_backing_branch(test, 'branch')
b = branch.Branch.open('branch')
- # We need to keep a reference to the branch as the Store uses a weak
- # ref. Referring to it in a lambda should be enough.
- test.addCleanup(lambda : b)
+ keep_branch_alive(test, b)
return config.BranchStack(b)
config.test_stack_builder_registry.register('branch', build_branch_stack)
@@ -150,9 +159,7 @@
(transport_class, server_class) = remote.get_test_permutations()[0]
build_backing_branch(test, 'branch', transport_class, server_class)
b = branch.Branch.open(test.get_url('branch'))
- # We need to keep a reference to the branch as the Store uses a weak
- # ref. Referring to it in a lambda should be enough.
- test.addCleanup(lambda : b)
+ keep_branch_alive(test, b)
return config.BranchStack(b)
config.test_stack_builder_registry.register('remote_branch',
build_remote_branch_stack)
More information about the bazaar-commits
mailing list