Rev 5485: Merge config-editor-option into next in file:///home/vila/src/bzr/experimental/config/

Vincent Ladeuil v.ladeuil+lp at free.fr
Tue May 31 19:27:01 UTC 2011


At file:///home/vila/src/bzr/experimental/config/

------------------------------------------------------------
revno: 5485 [merge]
revision-id: v.ladeuil+lp at free.fr-20110531192701-1jiukbs049nkyfm9
parent: v.ladeuil+lp at free.fr-20110531154933-2elp2fah12lpavc6
parent: v.ladeuil+lp at free.fr-20110531192700-ujeomhq93ga4jedq
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: next
timestamp: Tue 2011-05-31 21:27:01 +0200
message:
  Merge config-editor-option into next
modified:
  bzrlib/tests/test_config.py    testconfig.py-20051011041908-742d0c15d8d8c8eb
-------------- next part --------------
=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py	2011-05-31 15:49:33 +0000
+++ b/bzrlib/tests/test_config.py	2011-05-31 19:27:01 +0000
@@ -108,12 +108,26 @@
         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)
 
@@ -124,9 +138,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)
@@ -141,9 +153,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)
 
@@ -154,9 +164,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)
@@ -2257,6 +2265,12 @@
 
 
 class TestConcurrentStoreUpdates(TestStore):
+    """Test that Stores properly handle conccurent updates.
+
+    New Store implementation may fail some of these tests but until such
+    implementations exist it's hard to properly filter them from the scenarios
+    applied here. If you encounter such a case, contact the bzr devs.
+    """
 
     scenarios = [(key, {'get_stack': builder}) for key, builder
                  in config.test_stack_builder_registry.iteritems()]



More information about the bazaar-commits mailing list