Rev 3179: Using a static method as an attribute in a test class interact badly in a rather obscure way with pickle. in file:///v/home/vila/src/bzr/experimental/selftest/

Vincent Ladeuil v.ladeuil+lp at free.fr
Thu Jan 10 22:56:38 GMT 2008


At file:///v/home/vila/src/bzr/experimental/selftest/

------------------------------------------------------------
revno: 3179
revision-id:v.ladeuil+lp at free.fr-20080110225634-e9kcurnmy8ynoyni
parent: v.ladeuil+lp at free.fr-20080110223112-a4emv5adley9ncz7
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: selftest
timestamp: Thu 2008-01-10 23:56:34 +0100
message:
  Using a static method as an attribute in a test class interact badly in a rather obscure way with pickle.
  
  * bzrlib/tests/__init__.py:
  (save_test_list): Remove the pickler.clear_memo so that further
  obscure data sharing between tests can be catched.
  
  * bzrlib/tests/intertree_implementations/__init__.py:
  (make_source_parent_tree): Move from bzrlib/workingtree_4.py.
  
  * bzrlib/workingtree_4.py:
  (InterDirStateTree.make_source_parent_tree): Moved to
  bzrlib/tests/intertree_implementations/__init__.py. It's used only
  by tests and interact badly with pickle.
modified:
  bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
  bzrlib/tests/intertree_implementations/__init__.py __init__.py-20060724101752-09ysswo1a92uqyoz-3
  bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
-------------- next part --------------
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2008-01-10 22:31:12 +0000
+++ b/bzrlib/tests/__init__.py	2008-01-10 22:56:34 +0000
@@ -2736,8 +2736,6 @@
 
         try:
             pickler.dump(t)
-            # Tests should not share any data isn't it ?
-            pickler.clear_memo()
         except cPickle.PicklingError, e:
             ftest.truncate(fpos) # Get rid of partial pickle
             ftest.seek(fpos, 0)

=== modified file 'bzrlib/tests/intertree_implementations/__init__.py'
--- a/bzrlib/tests/intertree_implementations/__init__.py	2007-06-28 07:15:28 +0000
+++ b/bzrlib/tests/intertree_implementations/__init__.py	2008-01-10 22:56:34 +0000
@@ -95,6 +95,13 @@
         return result
 
 
+def make_source_parent_tree(source, target):
+    """Change the source tree into a parent of the target."""
+    revid = source.commit('record tree')
+    target.branch.repository.fetch(source.branch.repository, revid)
+    target.set_parent_ids([revid])
+    return target.basis_tree(), target
+
 def test_suite():
     result = TestSuite()
     loader = TestLoader()
@@ -114,7 +121,7 @@
             (optimiser,
              optimiser._matching_from_tree_format,
              optimiser._matching_to_tree_format,
-             optimiser._test_mutable_trees_to_test_trees))
+             make_source_parent_tree))
     adapter = InterTreeTestProviderAdapter(
         default_transport,
         # None here will cause a readonly decorator to be created

=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py	2007-12-29 21:28:32 +0000
+++ b/bzrlib/workingtree_4.py	2008-01-10 22:56:34 +0000
@@ -1716,17 +1716,8 @@
         if not InterDirStateTree.is_compatible(source, target):
             raise Exception, "invalid source %r and target %r" % (source, target)
 
-    @staticmethod
-    def make_source_parent_tree(source, target):
-        """Change the source tree into a parent of the target."""
-        revid = source.commit('record tree')
-        target.branch.repository.fetch(source.branch.repository, revid)
-        target.set_parent_ids([revid])
-        return target.basis_tree(), target
-
     _matching_from_tree_format = WorkingTreeFormat4()
     _matching_to_tree_format = WorkingTreeFormat4()
-    _test_mutable_trees_to_test_trees = make_source_parent_tree
 
     def _iter_changes(self, include_unchanged=False,
                       specific_files=None, pb=None, extra_trees=[],



More information about the bazaar-commits mailing list