Rev 4619: Cleanup test classes. in file:///home/vila/src/bzr/experimental/conflict-manager/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Fri Oct 16 14:05:31 BST 2009
At file:///home/vila/src/bzr/experimental/conflict-manager/
------------------------------------------------------------
revno: 4619
revision-id: v.ladeuil+lp at free.fr-20091016130531-ephd6kxja5ic3bb0
parent: v.ladeuil+lp at free.fr-20091016125947-smnlc9zxf58uf2r9
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: description
timestamp: Fri 2009-10-16 15:05:31 +0200
message:
Cleanup test classes.
* bzrlib/tests/blackbox/test_conflicts.py:
(TestBase): A new helper.
(TestConflicts, TestResolve): One class for each command.
(TestResolve.test_resolve_in_subdir): No need to restore the
current dir.
-------------- next part --------------
=== modified file 'bzrlib/tests/blackbox/test_conflicts.py'
--- a/bzrlib/tests/blackbox/test_conflicts.py 2009-10-16 12:59:47 +0000
+++ b/bzrlib/tests/blackbox/test_conflicts.py 2009-10-16 13:05:31 +0000
@@ -25,10 +25,9 @@
# FIXME: These don't really look at the output of the conflict commands, just
# the number of lines - there should be more examination.
-class TestConflicts(tests.TestCaseWithTransport):
+class TestBase(tests.TestCaseWithTransport):
- def setUp(self):
- super(TestConflicts, self).setUp()
+ def make_tree_with_conflicts(self):
a_tree = self.make_branch_and_tree('a')
self.build_tree_contents([
('a/myfile', 'contentsa\n'),
@@ -55,6 +54,13 @@
a_tree.merge_from_branch(b_tree.branch)
os.chdir('a')
+
+class TestConflicts(TestBase):
+
+ def setUp(self):
+ super(TestConflicts, self).setUp()
+ self.make_tree_with_conflicts()
+
def test_conflicts(self):
conflicts, errs = self.run_bzr('conflicts')
self.assertEqual(3, len(conflicts.splitlines()))
@@ -63,6 +69,13 @@
conflicts = self.run_bzr('conflicts --text')[0].splitlines()
self.assertEqual(['my_other_file', 'myfile'], conflicts)
+
+class TestResolve(TestBase):
+
+ def setUp(self):
+ super(TestResolve, self).setUp()
+ self.make_tree_with_conflicts()
+
def test_resolve(self):
self.run_bzr('resolve myfile')
conflicts, errs = self.run_bzr('conflicts')
@@ -79,19 +92,15 @@
def test_resolve_in_subdir(self):
"""resolve when run from subdirectory should handle relative paths"""
- orig_dir = os.getcwdu()
- try:
- os.mkdir("subdir")
- os.chdir("subdir")
- self.run_bzr("resolve ../myfile")
- os.chdir("../../b")
- self.run_bzr("resolve ../a/myfile")
- wt = workingtree.WorkingTree.open_containing('.')[0]
- conflicts = wt.conflicts()
- if not conflicts.is_empty():
- self.fail("tree still contains conflicts: %r" % conflicts)
- finally:
- os.chdir(orig_dir)
+ os.mkdir("subdir")
+ os.chdir("subdir")
+ self.run_bzr("resolve ../myfile")
+ os.chdir("../../b")
+ self.run_bzr("resolve ../a/myfile")
+ wt = workingtree.WorkingTree.open_containing('.')[0]
+ conflicts = wt.conflicts()
+ if not conflicts.is_empty():
+ self.fail("tree still contains conflicts: %r" % conflicts)
def test_auto_resolve(self):
"""Text conflicts can be resolved automatically"""
@@ -110,3 +119,4 @@
self.build_tree_contents([('file', 'a\n')])
note = self.run_bzr('resolve')[1]
self.assertContainsRe(note, 'All conflicts resolved.')
+
More information about the bazaar-commits
mailing list