[MERGE] Convert tests.blackbox.test_merge to use internals where appropriate

Aaron Bentley aaron.bentley at utoronto.ca
Wed Aug 8 14:24:08 BST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Daniel Watkins wrote:
> Attached is a fix for tests.blackbox.test_merge.

BB:resubmit

+    def example_branch(self, path='.'):
+        tree = self.make_branch_and_tree(path)
+        self.build_tree_contents([
+            (path + '/hello',   'foo'),
+            (path + '/goodbye', 'baz')])

For generating paths, you should typically use osutils.pathjoin

@@ -49,31 +51,27 @@

     def test_merge(self):
         from bzrlib.branch import Branch
- -
- -        os.mkdir('a')
- -        os.chdir('a')
- -        self.example_branch()
- -        ancestor = Branch.open('.').revno()
- -        os.chdir('..')
- -        self.run_bzr('branch a b')
- -        os.chdir('b')
- -        file('goodbye', 'wt').write('quux')
- -        self.run_bzr(['commit',  '-m',  "more u's are always good"])
- -
- -        os.chdir('../a')
- -        file('hello', 'wt').write('quuux')
+
+        a_tree = self.example_branch('a')
+        ancestor = Branch.open('a').revno()

^^ you can just do a_tree.branch.revno()

- -        print >> file('sub/a.txt', 'wb'), "hello"
- -        print >> file('b.txt', 'wb'), "hello"
- -        print >> file('sub/c.txt', 'wb'), "hello"

^^^ Man, did I really write this?

- -        self.assert_(os.path.exists('sub/a.txt.THIS'))
- -        self.assert_(os.path.exists('sub/a.txt.BASE'))
+        self.assertTrue(os.path.exists('sub/a.txt.THIS'))
+        self.assertTrue(os.path.exists('sub/a.txt.BASE'))

^^^ we now have failIfExists and failUnlessExists, so it would be better
to use those.

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGucP40F+nu1YWqI0RAvRMAJ9CGjboebKed5P/djouXokZ/dEC7wCfWlhZ
oFVMXrD8D1XUyi0kxbydIok=
=nGrb
-----END PGP SIGNATURE-----



More information about the bazaar mailing list