Rev 2761: (Daniel Watkins) Convert tests.blackbox.test_d* to use internals in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Tue Aug 28 14:48:45 BST 2007
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 2761
revision-id: pqm at pqm.ubuntu.com-20070828134844-fg5g3a447hu2h8u7
parent: pqm at pqm.ubuntu.com-20070828130228-rv0k8180v9n4vj90
parent: ian.clatworthy at internode.on.net-20070828131521-x61q7xcipcgtpcbk
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2007-08-28 14:48:44 +0100
message:
(Daniel Watkins) Convert tests.blackbox.test_d* to use internals
modified:
bzrlib/tests/blackbox/test_diff.py test_diff.py-20060110203741-aa99ac93e633d971
------------------------------------------------------------
revno: 2760.1.1
merged: ian.clatworthy at internode.on.net-20070828131521-x61q7xcipcgtpcbk
parent: pqm at pqm.ubuntu.com-20070828130228-rv0k8180v9n4vj90
parent: d.m.watkins at warwick.ac.uk-20070823180950-1kp28s684fo7y4fi
committer: Ian Clatworthy <ian.clatworthy at internode.on.net>
branch nick: ianc-integration
timestamp: Tue 2007-08-28 23:15:21 +1000
message:
(Daniel Watkins) Convert tests.blackbox.test_d* to use internals
------------------------------------------------------------
revno: 2738.1.3
merged: d.m.watkins at warwick.ac.uk-20070823180950-1kp28s684fo7y4fi
parent: d.m.watkins at warwick.ac.uk-20070821150858-5vmfntk0v0ydy85n
committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
branch nick: fix_blackbox_test_diff
timestamp: Thu 2007-08-23 20:09:50 +0200
message:
Fixed whitespace issues.
------------------------------------------------------------
revno: 2738.1.2
merged: d.m.watkins at warwick.ac.uk-20070821150858-5vmfntk0v0ydy85n
parent: d.m.watkins at warwick.ac.uk-20070821142537-efwr0leyanm91wcq
committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
branch nick: fix_blackbox_test_diff
timestamp: Tue 2007-08-21 17:08:58 +0200
message:
Tests now run on both branches and checkouts.
------------------------------------------------------------
revno: 2738.1.1
merged: d.m.watkins at warwick.ac.uk-20070821142537-efwr0leyanm91wcq
parent: pqm at pqm.ubuntu.com-20070821044713-ttnupbvhlsbwh1he
parent: d.m.watkins at warwick.ac.uk-20070803154852-61u6qlm2j0ehum3a
committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
branch nick: fix_blackbox_test_diff
timestamp: Tue 2007-08-21 16:25:37 +0200
message:
Applied original changes.
------------------------------------------------------------
revno: 2664.10.1
merged: d.m.watkins at warwick.ac.uk-20070803154852-61u6qlm2j0ehum3a
parent: pqm at pqm.ubuntu.com-20070731122244-f1jemfecukeevugw
committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
branch nick: fix-blackbox-tests
timestamp: Fri 2007-08-03 16:48:52 +0100
message:
tests.blackbox.test_diff now uses internals where appropriate.
=== modified file 'bzrlib/tests/blackbox/test_diff.py'
--- a/bzrlib/tests/blackbox/test_diff.py 2007-08-20 13:07:12 +0000
+++ b/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)
More information about the bazaar-commits
mailing list