Rev 4621: Translate one more test. in file:///home/vila/src/bzr/experimental/conflict-manager/

Vincent Ladeuil v.ladeuil+lp at free.fr
Sun Feb 28 13:58:03 GMT 2010


At file:///home/vila/src/bzr/experimental/conflict-manager/

------------------------------------------------------------
revno: 4621
revision-id: v.ladeuil+lp at free.fr-20100228135803-yrsc4pu9e4bvbf1h
parent: v.ladeuil+lp at free.fr-20100228134428-axphf2el34r17qfr
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: cleanup
timestamp: Sun 2010-02-28 14:58:03 +0100
message:
  Translate one more test.
  
  * bzrlib/tests/test_conflicts.py:
  (TestResolveContentConflicts): Rewrite test_resolve_taking_other as
  a whitebox test, refactoring common code.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_conflicts.py'
--- a/bzrlib/tests/test_conflicts.py	2010-02-28 13:44:28 +0000
+++ b/bzrlib/tests/test_conflicts.py	2010-02-28 13:58:03 +0000
@@ -215,22 +215,39 @@
         builder.finish_series()
         self.builder = builder
 
-    def test_resolve_taking_this(self):
+    def _merge_other_into_this(self):
         b = self.builder.get_branch()
         wt = b.bzrdir.sprout('branch').open_workingtree()
         wt.merge_from_branch(b, 'other')
-        # Check that we got the right conflict
+        return wt
+
+    def assertConflict(self, wt, ctype, **kwargs):
         confs = wt.conflicts()
         self.assertEqual(1, len(confs))
         c = confs[0]
-        self.assertIsInstance(confs[0], conflicts.ContentsConflict)
-        self.assertEqual('file-id', c.file_id)
-        self.assertEqual('file', c.path)
-        conflicts.resolve(wt, ['file'], action='take_this')
+        self.assertIsInstance(c, ctype)
+        sentinel = object() # An impossible value
+        for k, v in kwargs.iteritems():
+            self.assertEqual(v, getattr(c, k, sentinel))
+
+    def assertResolved(self, wt, item, action):
+        conflicts.resolve(wt, [item], action=action)
         # Check that we don't have any conflicts nor unknown left
         self.assertEqual(0, len(wt.conflicts()))
         self.assertEqual(0, len(list(wt.unknowns())))
 
+    def test_resolve_taking_this(self):
+        wt = self._merge_other_into_this()
+        self.assertConflict(wt, conflicts.ContentsConflict,
+                            path='file', file_id='file-id',)
+        self.assertResolved(wt, 'file', 'take_this')
+
+    def test_resolve_taking_other(self):
+        wt = self._merge_other_into_this()
+        self.assertConflict(wt, conflicts.ContentsConflict,
+                            path='file', file_id='file-id',)
+        self.assertResolved(wt, 'file', 'take_other')
+
 
 class OldTestResolveContentConflicts(TestResolveConflicts):
 



More information about the bazaar-commits mailing list