Rev 2705: tests.blackbox.test_a* use internals where appropriate (Daniel Watkins) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Aug 15 16:56:42 BST 2007


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 2705
revision-id: pqm at pqm.ubuntu.com-20070815155635-7o7uhuh1ggjomeh4
parent: pqm at pqm.ubuntu.com-20070815145844-2vp9dc8e2nz8qusk
parent: d.m.watkins at warwick.ac.uk-20070803101344-9sjidnh5baksi5pp
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2007-08-15 16:56:35 +0100
message:
  tests.blackbox.test_a* use internals where appropriate (Daniel Watkins)
modified:
  bzrlib/tests/blackbox/test_added.py test_added.py-20060119085008-6b8b90369d42a26c
  bzrlib/tests/blackbox/test_aliases.py test_aliases.py-20060210230318-f0c08c9294dbfae1
  bzrlib/tests/blackbox/test_ancestry.py test_ancestry.py-20060131142602-6d9524c490537e90
    ------------------------------------------------------------
    revno: 2664.6.3
    merged: d.m.watkins at warwick.ac.uk-20070803101344-9sjidnh5baksi5pp
    parent: d.m.watkins at warwick.ac.uk-20070802180435-cs6xalg5tkze209b
    committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
    branch nick: fix-blackbox-tests
    timestamp: Fri 2007-08-03 11:13:44 +0100
    message:
      tests.blackbox.test_ancestry now uses internals where appropriate.
    ------------------------------------------------------------
    revno: 2664.6.2
    merged: d.m.watkins at warwick.ac.uk-20070802180435-cs6xalg5tkze209b
    parent: d.m.watkins at warwick.ac.uk-20070802175539-rkvp93c7yygw4fxu
    committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
    branch nick: fix-blackbox-tests
    timestamp: Thu 2007-08-02 19:04:35 +0100
    message:
      tests.blackbox.test_aliases now uses internals where appropriate.
    ------------------------------------------------------------
    revno: 2664.6.1
    merged: d.m.watkins at warwick.ac.uk-20070802175539-rkvp93c7yygw4fxu
    parent: pqm at pqm.ubuntu.com-20070731122244-f1jemfecukeevugw
    committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
    branch nick: fix-blackbox-tests
    timestamp: Thu 2007-08-02 18:55:39 +0100
    message:
      tests.blackbox.test_added now uses internals where appropriate.
=== modified file 'bzrlib/tests/blackbox/test_added.py'
--- a/bzrlib/tests/blackbox/test_added.py	2007-06-28 12:26:11 +0000
+++ b/bzrlib/tests/blackbox/test_added.py	2007-08-02 17:55:39 +0000
@@ -21,10 +21,9 @@
 import os
 
 from bzrlib.branch import Branch
-from bzrlib.tests import TestCaseInTempDir
-from bzrlib.tests.treeshape import build_tree_contents
+from bzrlib.tests.blackbox import ExternalBase
 
-class TestAdded(TestCaseInTempDir):
+class TestAdded(ExternalBase):
 
     def test_added(self):
         """Test that 'added' command reports added files"""
@@ -34,23 +33,20 @@
             self.assertEquals(out, expected)
             self.assertEquals(err, '')
 
-        def bzr(*args):
-            self.run_bzr(*args)
-
         # in empty directory, nothing added
-        bzr('init')
+        tree = self.make_branch_and_tree('.')
         check_added('')
 
         # with unknown file, still nothing added
-        build_tree_contents([('a', 'contents of a\n')])
+        self.build_tree_contents([('a', 'contents of a\n')])
         check_added('')
 
         # after add, shows up in list
         # bug report 20060119 by Nathan McCallum -- 'bzr added' causes
         # NameError
-        bzr('add a')
+        tree.add('a')
         check_added('a\n')
 
         # after commit, now no longer listed
-        bzr(['commit', '-m', 'add a'])
+        tree.commit(message='add a')
         check_added('')

=== modified file 'bzrlib/tests/blackbox/test_aliases.py'
--- a/bzrlib/tests/blackbox/test_aliases.py	2007-06-26 20:32:49 +0000
+++ b/bzrlib/tests/blackbox/test_aliases.py	2007-08-02 18:04:35 +0000
@@ -19,12 +19,12 @@
 import os
 
 from bzrlib.branch import Branch
-from bzrlib.tests import TestCaseInTempDir
+from bzrlib.tests.blackbox import ExternalBase
 from bzrlib.trace import mutter
 from bzrlib.config import (ensure_config_dir_exists, config_filename)
 
 
-class TestAliases(TestCaseInTempDir):
+class TestAliases(ExternalBase):
 
     def test_aliases(self):
 
@@ -39,7 +39,7 @@
             # Something is wrong in environment, 
             # we risk overwriting users config 
             self.assert_(config_filename() + "exists, abort")
-        
+
         ensure_config_dir_exists()
         CONFIG=("[ALIASES]\n"
                 "c=cat\n"
@@ -48,20 +48,18 @@
 
         open(config_filename(),'wb').write(CONFIG)
 
-
         str1 = 'foo\n'
         str2 = 'bar\n'
 
-        bzr('init')
-        open('a', 'wb').write(str1)
-        bzr('add a')
-
-        bzr('commit -m 1')
+        tree = self.make_branch_and_tree('.')
+        self.build_tree_contents([('a', str1)])
+        tree.add('a')
+        tree.commit(message='1')
 
         self.assertEquals(bzr('c a'), str1)
 
-        open('a', 'wb').write(str2)
-        bzr('commit -m 2')
+        self.build_tree_contents([('a', str2)])
+        tree.commit(message='2')
 
         self.assertEquals(bzr('c a'), str2)
         self.assertEquals(bzr('c1 a'), str1)

=== modified file 'bzrlib/tests/blackbox/test_ancestry.py'
--- a/bzrlib/tests/blackbox/test_ancestry.py	2007-07-25 22:03:13 +0000
+++ b/bzrlib/tests/blackbox/test_ancestry.py	2007-08-03 10:13:44 +0000
@@ -25,18 +25,21 @@
 
     def _build_branches(self):
         a_wt = self.make_branch_and_tree('A')
-        open('A/foo', 'wb').write('1111\n')
+        self.build_tree_contents([('A/foo', '1111\n')])
         a_wt.add('foo')
         a_wt.commit('added foo',rev_id='A1')
-        self.run_bzr('branch A B')
-        b_wt = WorkingTree.open('B')
-        open('B/foo','wb').write('1111\n22\n')
+
+        b_wt = a_wt.bzrdir.sprout('B').open_workingtree()
+        self.build_tree_contents([('B/foo', '1111\n22\n')])
         b_wt.commit('modified B/foo',rev_id='B1')
-        open('A/foo', 'wb').write('000\n1111\n')
+
+        self.build_tree_contents([('A/foo', '000\n1111\n')])
         a_wt.commit('modified A/foo',rev_id='A2')
+
         a_wt.merge_from_branch(b_wt.branch, b_wt.last_revision(),
             b_wt.branch.get_rev_id(1))
         a_wt.commit('merged B into A',rev_id='A3')
+        return a_wt, b_wt
 
     def _check_ancestry(self, location='', result=None):
         out = self.run_bzr(['ancestry', location])[0]
@@ -58,43 +61,48 @@
     def test_ancestry_with_repo_branch(self):
         """Tests 'ancestry' command with a location that is a
         repository branch."""
-        self._build_branches()
-        self.run_bzr('init-repo repo')
-        self.run_bzr('branch A repo/A')
+        a_tree = self._build_branches()[0]
+
+        self.make_repository('repo', shared=True)
+
+        a_tree.bzrdir.sprout('repo/A')
         self._check_ancestry('repo/A')
 
     def test_ancestry_with_checkout(self):
         """Tests 'ancestry' command with a location that is a
         checkout of a repository branch."""
-        self._build_branches()
-        self.run_bzr('init-repo repo')
-        self.run_bzr('branch A repo/A')
-        self.run_bzr('checkout repo/A A-checkout')
+        a_tree = self._build_branches()[0]
+        self.make_repository('repo', shared=True)
+        repo_branch = a_tree.bzrdir.sprout('repo/A').open_branch()
+        repo_branch.create_checkout('A-checkout')
         self._check_ancestry('A-checkout')
 
     def test_ancestry_with_lightweight_checkout(self):
         """Tests 'ancestry' command with a location that is a
         lightweight checkout of a repository branch."""
-        self._build_branches()
-        self.run_bzr('init-repo repo')
-        self.run_bzr('branch A repo/A')
-        self.run_bzr('checkout --lightweight repo/A A-checkout')
+        a_tree = self._build_branches()[0]
+        self.make_repository('repo', shared=True)
+        repo_branch = a_tree.bzrdir.sprout('repo/A').open_branch()
+        repo_branch.create_checkout('A-checkout', lightweight=True)
         self._check_ancestry('A-checkout')
 
     def test_ancestry_with_truncated_checkout(self):
         """Tests 'ancestry' command with a location that is a
         checkout of a repository branch with a shortened revision history."""
-        self._build_branches()
-        self.run_bzr('init-repo repo')
-        self.run_bzr('branch A repo/A')
-        self.run_bzr('checkout -r 2 repo/A A-checkout')
+        a_tree = self._build_branches()[0]
+        self.make_repository('repo', shared=True)
+        repo_branch = a_tree.bzrdir.sprout('repo/A').open_branch()
+        repo_branch.create_checkout('A-checkout',
+                                    revision_id=repo_branch.get_rev_id(2))
         self._check_ancestry('A-checkout', "A1\nA2\n")
 
     def test_ancestry_with_truncated_lightweight_checkout(self):
         """Tests 'ancestry' command with a location that is a lightweight
         checkout of a repository branch with a shortened revision history."""
-        self._build_branches()
-        self.run_bzr('init-repo repo')
-        self.run_bzr('branch A repo/A')
-        self.run_bzr('checkout -r 2 --lightweight repo/A A-checkout')
+        a_tree = self._build_branches()[0]
+        self.make_repository('repo', shared=True)
+        repo_branch = a_tree.bzrdir.sprout('repo/A').open_branch()
+        repo_branch.create_checkout('A-checkout',
+                                    revision_id=repo_branch.get_rev_id(2),
+                                    lightweight=True)
         self._check_ancestry('A-checkout', "A1\nA2\n")




More information about the bazaar-commits mailing list