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

Daniel Watkins D.M.Watkins at warwick.ac.uk
Thu Aug 23 19:10:51 BST 2007


On Thu, 2007-08-23 at 12:47 -0400, Aaron Bentley wrote:
> More whitespace issues.  Otherwise good.
Fixed in attached.

-- 
Daniel Watkins (Odd_Bloke) <D.M.Watkins at warwick.ac.uk>
University of Warwick Christian Focus President
University of Warwick Computing Society WUGLUG Liaison Officer
-------------- next part --------------
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: d.m.watkins at warwick.ac.uk-20070823180950-\
#   1kp28s684fo7y4fi
# target_branch: file:///home/daniel/devel/bzr/bzr.dev/
# testament_sha1: f46ad8c35bf1504295aaff65a941c8c17f525b63
# timestamp: 2007-08-23 20:10:00 +0200
# base_revision_id: pqm at pqm.ubuntu.com-20070821044713-ttnupbvhlsbwh1he
# 
# Begin patch
=== modified file 'bzrlib/tests/blackbox/test_diff.py'
--- bzrlib/tests/blackbox/test_diff.py	2007-08-20 13:07:12 +0000
+++ bzrlib/tests/blackbox/test_diff.py	2007-08-23 18:09:50 +0000
@@ -38,36 +38,37 @@
     """Base class with common setup method"""
 
     def make_example_branch(self):
-        # FIXME: copied from test_too_much -- share elsewhere?
         tree = self.make_branch_and_tree('.')
-        open('hello', 'wb').write('foo\n')
+        self.build_tree_contents([
+            ('hello', 'foo\n'),
+            ('goodbye', 'baz\n')])
         tree.add(['hello'])
         tree.commit('setup')
-        open('goodbye', 'wb').write('baz\n')
         tree.add(['goodbye'])
         tree.commit('setup')
+        return tree
 
 
 class TestDiff(DiffBase):
 
     def test_diff(self):
-        self.make_example_branch()
-        file('hello', 'wt').write('hello world!')
-        self.run_bzr('commit -m fixing hello')
+        tree = self.make_example_branch()
+        self.build_tree_contents([('hello', 'hello world!')])
+        tree.commit(message='fixing hello')
         output = self.run_bzr('diff -r 2..3', retcode=1)[0]
         self.assert_('\n+hello world!' in output)
         output = self.run_bzr('diff -r last:3..last:1',
                 retcode=1)[0]
         self.assert_('\n+baz' in output)
         self.build_tree(['moo'])
-        self.run_bzr('add moo')
+        tree.add('moo')
         os.unlink('moo')
         self.run_bzr('diff')
 
     def test_diff_prefix(self):
         """diff --prefix appends to filenames in output"""
         self.make_example_branch()
-        file('hello', 'wb').write('hello world!\n')
+        self.build_tree_contents([('hello', 'hello world!\n')])
         out, err = self.run_bzr('diff --prefix old/:new/', retcode=1)
         self.assertEquals(err, '')
         self.assertEqualDiff(subst_dates(out), '''\
@@ -89,7 +90,7 @@
     def test_diff_p1(self):
         """diff -p1 produces lkml-style diffs"""
         self.make_example_branch()
-        file('hello', 'wb').write('hello world!\n')
+        self.build_tree_contents([('hello', 'hello world!\n')])
         out, err = self.run_bzr('diff -p1', retcode=1)
         self.assertEquals(err, '')
         self.assertEqualDiff(subst_dates(out), '''\
@@ -105,7 +106,7 @@
     def test_diff_p0(self):
         """diff -p0 produces diffs with no prefix"""
         self.make_example_branch()
-        file('hello', 'wb').write('hello world!\n')
+        self.build_tree_contents([('hello', 'hello world!\n')])
         out, err = self.run_bzr('diff -p0', retcode=1)
         self.assertEquals(err, '')
         self.assertEqualDiff(subst_dates(out), '''\
@@ -140,13 +141,14 @@
     # TODO: What should diff say for a file deleted in working tree?
 
     def example_branches(self):
-        self.build_tree(['branch1/', 'branch1/file'], line_endings='binary')
-        self.run_bzr('init branch1')[0]
-        self.run_bzr('add branch1/file')[0]
-        self.run_bzr(['commit', '-m', 'add file', 'branch1'])
-        self.run_bzr('branch branch1 branch2')[0]
+        branch1_tree = self.make_branch_and_tree('branch1')
+        self.build_tree(['branch1/file'], line_endings='binary')
+        branch1_tree.add('file')
+        branch1_tree.commit(message='add file')
+        branch2_tree = branch1_tree.bzrdir.sprout('branch2').open_workingtree()
         self.build_tree_contents([('branch2/file', 'new content\n')])
-        self.run_bzr(['commit', '-m', 'update file', 'branch2'])
+        branch2_tree.commit(message='update file')
+        return branch1_tree, branch2_tree
 
     def test_diff_branches(self):
         self.example_branches()
@@ -174,9 +176,9 @@
 
     def test_diff_revno_branches(self):
         self.example_branches()
-        print >> open('branch2/file', 'wb'), 'even newer content'
-        self.run_bzr(['commit', '-m',
-                      'update file once more', 'branch2'])
+        branch2_tree = workingtree.WorkingTree.open_containing('branch2')[0]
+        self.build_tree_contents([('branch2/file', 'even newer content')])
+        branch2_tree.commit(message='update file once more')
 
         out, err = self.run_bzr('diff -r revno:1:branch2..revno:1:branch1',
                                 )
@@ -194,29 +196,25 @@
                               "\n", subst_dates(out))
 
     def example_branch2(self):
-        self.build_tree(['branch1/', 'branch1/file1'], line_endings='binary')
-        self.run_bzr('init branch1')[0]
-        self.run_bzr('add branch1/file1')[0]
-        print >> open('branch1/file1', 'wb'), 'original line'
-        self.run_bzr(['commit', '-m', 'first commit', 'branch1'])
-        
-        print >> open('branch1/file1', 'wb'), 'repo line'
-        self.run_bzr(['commit', '-m', 'second commit', 'branch1'])
+        branch1_tree = self.make_branch_and_tree('branch1')
+        self.build_tree_contents([('branch1/file1', 'original line\n')])
+        branch1_tree.add('file1')
+        branch1_tree.commit(message='first commit')
+        self.build_tree_contents([('branch1/file1', 'repo line\n')])
+        branch1_tree.commit(message='second commit')
+        return branch1_tree
 
     def test_diff_to_working_tree(self):
         self.example_branch2()
-        
-        print >> open('branch1/file1', 'wb'), 'new line'
-        output = self.run_bzr('diff -r 1.. branch1',
-                              retcode=1)
+        self.build_tree_contents([('branch1/file1', 'new line')])
+        output = self.run_bzr('diff -r 1.. branch1', retcode=1)
         self.assertContainsRe(output[0], '\n\\-original line\n\\+new line\n')
 
     def test_diff_across_rename(self):
         """The working tree path should always be considered for diffing"""
-        self.make_example_branch()
+        tree = self.make_example_branch()
         self.run_bzr('diff -r 0..1 hello', retcode=1)
-        wt = workingtree.WorkingTree.open_containing('.')[0]
-        wt.rename_one('hello', 'hello1')
+        tree.rename_one('hello', 'hello1')
         self.run_bzr('diff hello1', retcode=1)
         self.run_bzr('diff -r 0..1 hello1', retcode=1)
 
@@ -224,48 +222,51 @@
 class TestCheckoutDiff(TestDiff):
 
     def make_example_branch(self):
-        super(TestCheckoutDiff, self).make_example_branch()
-        self.run_bzr('checkout . checkout')
+        tree = super(TestCheckoutDiff, self).make_example_branch()
+        tree = tree.branch.create_checkout('checkout')
         os.chdir('checkout')
+        return tree
 
     def example_branch2(self):
-        super(TestCheckoutDiff, self).example_branch2()
+        tree = super(TestCheckoutDiff, self).example_branch2()
         os.mkdir('checkouts')
-        self.run_bzr('checkout branch1 checkouts/branch1')
+        tree = tree.branch.create_checkout('checkouts/branch1')
         os.chdir('checkouts')
+        return tree
 
     def example_branches(self):
-        super(TestCheckoutDiff, self).example_branches()
+        branch1_tree, branch2_tree = super(TestCheckoutDiff, self).example_branches()
         os.mkdir('checkouts')
-        self.run_bzr('checkout branch1 checkouts/branch1')
-        self.run_bzr('checkout branch2 checkouts/branch2')
+        branch1_tree = branch1_tree.branch.create_checkout('checkouts/branch1')
+        branch2_tree = branch2_tree.branch.create_checkout('checkouts/branch2')
         os.chdir('checkouts')
+        return branch1_tree, branch2_tree
 
 
 class TestDiffLabels(DiffBase):
 
     def test_diff_label_removed(self):
-        super(TestDiffLabels, self).make_example_branch()
-        self.run_bzr('remove hello')
+        tree = super(TestDiffLabels, self).make_example_branch()
+        tree.remove('hello', keep_files=False)
         diff = self.run_bzr('diff', retcode=1)
         self.assertTrue("=== removed file 'hello'" in diff[0])
 
     def test_diff_label_added(self):
-        super(TestDiffLabels, self).make_example_branch()
-        file('barbar', 'wt').write('barbar')
-        self.run_bzr('add barbar')
+        tree = super(TestDiffLabels, self).make_example_branch()
+        self.build_tree_contents([('barbar', 'barbar')])
+        tree.add('barbar')
         diff = self.run_bzr('diff', retcode=1)
         self.assertTrue("=== added file 'barbar'" in diff[0])
 
     def test_diff_label_modified(self):
         super(TestDiffLabels, self).make_example_branch()
-        file('hello', 'wt').write('barbar')
+        self.build_tree_contents([('hello', 'barbar')])
         diff = self.run_bzr('diff', retcode=1)
         self.assertTrue("=== modified file 'hello'" in diff[0])
 
     def test_diff_label_renamed(self):
-        super(TestDiffLabels, self).make_example_branch()
-        self.run_bzr('rename hello gruezi')
+        tree = super(TestDiffLabels, self).make_example_branch()
+        tree.rename_one('hello', 'gruezi')
         diff = self.run_bzr('diff', retcode=1)
         self.assertTrue("=== renamed file 'hello' => 'gruezi'" in diff[0])
 
@@ -308,6 +309,6 @@
     def test_diff_output(self):
         # check that output doesn't mangle line-endings
         self.make_example_branch()
-        file('hello', 'wb').write('hello world!\n')
+        self.build_tree_contents([('hello', 'hello world!\n')])
         output = self.run_bzr_subprocess('diff', retcode=1)[0]
         self.assert_('\n+hello world!\n' in output)

# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWR9hWFkACN5fgARQcef//38G
BI6////wYA0cB3PvXiFFAoAAFVQUAAAAABQDUUMTaTEGjQYaQ9Q0MTQ0MRkAGik/RGUyAaAAGgAA
AaABFT/Uk/JNqmgANAAAAAAAASakQIk8k9pT1QNplA9PVP1Ro0GajTTagBzCYBMAJhMJpgAAEyaa
BgqSQCABGgmTImmmmCqenpgo0maPSWISdfDlw1vr5w6z1rVMQpixScGmF/dn957z9y3griG35uy+
wuw3JTLA2bJ670yWblFFlWO78K6wiAhOQMKydC23TS95lCYJIcGkxZNe2oTDDcbdszsWyv3aXcnD
AyzwmgY4GW3O9X2WLVmJco5EkIZkJN9fAKhSQw9vngeyW3SoCkIqgsOXIJL7+vHdbdbx0oMgo8cr
4vldOOGd7bZK16qrApiiTjKtfLAybOxNmdGTGEpsJwfBAPhCBg0a8pEaNVzorXgSGxQgJqsBuOBZ
saxpI0w6pq0YjykQw9XIpRkQjAhcmxGWQUSPq70DFgQsQyEdMD6BGqUgC4Pj8UhGALAfesOKbAsz
oxpVKopruHCJeGcsv0zu1xaOvZ4UohBmZAFAHwL4BQHrJi5inKZZ65UGbqSaSZ1nz4QQEt5557jy
MZIUe47OftU2PLTvdcsaplay2xmrNJbC3TMqxQGUWur1dQtUc2SWSxRSRkF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Z
HJC++dst8C8+MmKfchcjNHoi9L0b4fHRHonzPU5jfPajll7ScCfHplgbBSPs1ZbpRjyumB/qGBah
fhZCsWOguXX5yBVoll1rmUotOOvK4yqfMsWqRc+1xI0jNJb3ouiWoGxPGXEv49yZUS5LT28FSGvJ
BVvR8yyTszfLPmoN1bonsy19P4+kmuHLMnu5e/5ttSP3qTbuZQuS4t1y3/1R6nqehOkaDcsKCyOF
tVv9Yee/Yn99SqabDYKNW7nbuJ4Sban90Xk9ePCPKw9viiyb0nVAxNeWGGsbZCfrUk9I3zQT2+Hs
TsP7Fx2lRLo29NW6Q4Jft9uGKHTAZUPXVw4CMCqHsMWv3WsS0qypP3StLosKMBFvFJidNY6RKj2c
qHEcEFGhPPZxpJh7rEmUSpt1C7lrvpk32hZMuBwMhlMVKqQyPsKsZYS8oXxNxWm30O4o4z9vTiN5
1cxcNaNpIrbOESxOOtiqqjsigM1QaobK1IsYhMMUJjSRoDRJxNssnNLxrT7o5p+mmHznuiYCPWeZ
90YsJNk8mkNO3anT23JGz/8i3HUTXLIPoiplWDu9BHIh0RcwzmxxEd1k6Ix1HWlSpmj+O+9+l5NR
0OBahR/KeCLzC8pHYjh8vN8NkYxg/+F3JFOFCQH2FYWQ
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20070823/b2888015/attachment.pgp 


More information about the bazaar mailing list