Rev 6514: Fix a couple tests that wanted to directly create a wt where the branch was. in http://bazaar.launchpad.net/~jameinel/bzr/2.5-remote-wt-tests-1046697

John Arbash Meinel john at arbash-meinel.com
Thu Sep 6 09:28:51 UTC 2012


At http://bazaar.launchpad.net/~jameinel/bzr/2.5-remote-wt-tests-1046697

------------------------------------------------------------
revno: 6514
revision-id: john at arbash-meinel.com-20120906092825-kk4homlywkes77n5
parent: john at arbash-meinel.com-20120906090045-bu07u9xz0u59h1v3
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.5-remote-wt-tests-1046697
timestamp: Thu 2012-09-06 13:28:25 +0400
message:
  Fix a couple tests that wanted to directly create a wt where the branch was.
  It wasn't actually needed for the tests, they just wanted a cheap way to not
  run the test against trees that didn't support checkouts.
-------------- next part --------------
=== modified file 'bzrlib/tests/per_workingtree/test_remove.py'
--- a/bzrlib/tests/per_workingtree/test_remove.py	2011-05-13 12:51:05 +0000
+++ b/bzrlib/tests/per_workingtree/test_remove.py	2012-09-06 09:28:25 +0000
@@ -173,7 +173,7 @@
         """Removing a absent directory succeeds without corruption (#150438)."""
         paths = ['a/', 'a/b']
         tree = self.get_committed_tree(paths)
-        self.get_transport('.').delete_tree('a')
+        tree.bzrdir.root_transport.delete_tree('a')
         tree.remove(['a'])
         self.assertRemovedAndDeleted('b')
         tree._validate()

=== modified file 'bzrlib/tests/per_workingtree/test_smart_add.py'
--- a/bzrlib/tests/per_workingtree/test_smart_add.py	2011-09-06 09:51:45 +0000
+++ b/bzrlib/tests/per_workingtree/test_smart_add.py	2012-09-06 09:28:25 +0000
@@ -135,6 +135,9 @@
 
         self.build_tree(build_paths)
         wt = self.make_branch_and_tree('.')
+        if wt.user_url != wt.branch.user_url:
+            # Lightweight checkout, make sure we have a repo location.
+            wt.branch.bzrdir.root_transport.mkdir('original')
         child_tree = self.make_branch_and_tree('original/child')
         wt.smart_add((".",))
         for path in paths:

=== modified file 'bzrlib/tests/per_workingtree/test_workingtree.py'
--- a/bzrlib/tests/per_workingtree/test_workingtree.py	2012-01-25 21:13:15 +0000
+++ b/bzrlib/tests/per_workingtree/test_workingtree.py	2012-09-06 09:28:25 +0000
@@ -57,6 +57,16 @@
 
 class TestWorkingTree(TestCaseWithWorkingTree):
 
+    def requireBranchReference(self):
+        test_branch = self.make_branch('test-branch')
+        try:
+            # if there is a working tree now, this is not supported.
+            test_branch.bzrdir.open_workingtree()
+            raise TestNotApplicable("only on trees that can be separate"
+                " from their branch.")
+        except (errors.NoWorkingTree, errors.NotLocalUrl):
+            pass
+
     def test_branch_builder(self):
         # Just a smoke test that we get a branch at the specified relpath
         builder = self.make_branch_builder('foobar')
@@ -478,19 +488,19 @@
         # that formats where initialising a branch does not initialise a
         # tree - and thus have separable entities - support skewing the
         # two things.
-        main_branch = self.make_branch('tree')
+        test_branch = self.make_branch('test-branch')
         try:
             # if there is a working tree now, this is not supported.
-            main_branch.bzrdir.open_workingtree()
+            test_branch.bzrdir.open_workingtree()
             return
-        except errors.NoWorkingTree:
+        except (errors.NoWorkingTree, errors.NotLocalUrl):
             pass
-        wt = main_branch.bzrdir.create_workingtree()
+        wt = self.make_branch_and_tree('tree')
         # create an out of date working tree by making a checkout in this
         # current format
         self.build_tree(['checkout/', 'tree/file'])
         checkout = bzrdir.BzrDirMetaFormat1().initialize('checkout')
-        checkout.set_branch_reference(main_branch)
+        checkout.set_branch_reference(wt.branch)
         old_tree = self.workingtree_format.initialize(checkout)
         # now commit to 'tree'
         wt.add('file')
@@ -545,19 +555,13 @@
         # that formats where initialising a branch does not initialise a
         # tree - and thus have separable entities - support skewing the
         # two things.
-        main_branch = self.make_branch('tree')
-        try:
-            # if there is a working tree now, this is not supported.
-            main_branch.bzrdir.open_workingtree()
-            return
-        except errors.NoWorkingTree:
-            pass
-        wt = main_branch.bzrdir.create_workingtree()
+        self.requireBranchReference()
+        wt = self.make_branch_and_tree('tree')
         # create an out of date working tree by making a checkout in this
         # current format
         self.build_tree(['checkout/', 'tree/file'])
         checkout = bzrdir.BzrDirMetaFormat1().initialize('checkout')
-        checkout.set_branch_reference(main_branch)
+        checkout.set_branch_reference(wt.branch)
         old_tree = self.workingtree_format.initialize(checkout)
         # now commit to 'tree'
         wt.add('file')



More information about the bazaar-commits mailing list